You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2008/03/22 02:25:29 UTC
svn commit: r639933 - in /incubator/tuscany/branches/sca-java-1.2:
demos/alert-aggregator-webapp/
demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/
demos/bigbank/ demos/bigbank/src/main/java/bigbank/account/feed/ demo...
Author: jsdelfino
Date: Fri Mar 21 18:25:20 2008
New Revision: 639933
URL: http://svn.apache.org/viewvc?rev=639933&view=rev
Log:
Merged changes from trunk SVN revision r639931. Ported samples and demos to the new atom-abdera and rss-rome bindings. Fixed issues in the ATOM binding invoker preventing Abdera to perform lazy XML parsing.
Modified:
incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/pom.xml
incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java
incubator/tuscany/branches/sca-java-1.2/demos/bigbank/pom.xml
incubator/tuscany/branches/sca-java-1.2/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java
incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/pom.xml
incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/feed/AccountFeedImpl.java
incubator/tuscany/branches/sca-java-1.2/demos/xml-bigbank/pom.xml
incubator/tuscany/branches/sca-java-1.2/distribution/bundle/pom.xml
incubator/tuscany/branches/sca-java-1.2/distribution/manifest/pom.xml
incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/pom.xml
incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/pom.xml
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/pom.xml
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/Sort.java
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/SortImpl.java
incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/resources/FeedAggregator.composite
Modified: incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/pom.xml?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/pom.xml Fri Mar 21 18:25:20 2008
@@ -120,14 +120,13 @@
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
+ <artifactId>tuscany-binding-atom-abdera</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
- <scope>compile</scope>
</dependency>
<dependency>
- <groupId>rome</groupId>
- <artifactId>rome</artifactId>
- <version>0.9</version>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rss-rome</artifactId>
+ <version>2.0-incubating-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
Modified: incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java Fri Mar 21 18:25:20 2008
@@ -19,25 +19,19 @@
package org.apache.tuscany.sca.demos.aggregator;
-import java.io.InputStream;
import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.tuscany.sca.binding.feed.collection.Collection;
-import org.apache.tuscany.sca.binding.feed.collection.NotFoundException;
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
import org.apache.tuscany.sca.demos.aggregator.types.AlertType;
import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Feed;
-import com.sun.syndication.feed.synd.SyndEntry;
-import com.sun.syndication.feed.synd.SyndEntryImpl;
-import com.sun.syndication.feed.synd.SyndFeed;
-import com.sun.syndication.feed.synd.SyndFeedImpl;
-
/**
* Read all new alerts from the specified sources
*
@@ -56,81 +50,53 @@
DateFormat dateFormatter = DateFormat.getDateTimeInstance();
/**
- * Return the alerts as a feed. Used by binding.feed
+ * Return the alerts as a feed.
*
* @return the structure containing alerts
*/
- public Feed getFeed() {
+ public org.apache.abdera.model.Feed getFeed() {
// Create a new Feed
- SyndFeed feed = new SyndFeedImpl();
- feed.setTitle("Apache Tuscant Feed Aggregator");
- feed.setDescription("A sample showing an SCA application to aggregate various types of feeds");
- feed.setAuthor("Apache Tuscany");
- feed.setLink("http://incubator.apache.org/tuscany");
+ Factory factory = Abdera.getNewFactory();
+ Feed feed = factory.newFeed();
+ feed.setTitle("Apache Tuscany Feed Aggregator");
+ feed.setSubtitle("A sample showing an SCA application to aggregate various types of feeds");
+ feed.addAuthor("Apache Tuscany");
+ feed.addLink("http://incubator.apache.org/tuscany");
// Aggregate entries from feed1 and feed2
- List<SyndEntry> entries = new ArrayList<SyndEntry>();
-
try {
AlertsType alerts = this.alerts.getAllNewAlerts("");
for( Object alertObject : alerts.getAlert() ){
AlertType alert = ((AlertType)alertObject);
- SyndEntry entry = new SyndEntryImpl();
+ Entry entry = factory.newEntry();
entry.setTitle(alert.getTitle());
//entry.(alert.getSummary());
- entry.setLink(alert.getAddress());
- entry.setPublishedDate(dateFormatter.parse(alert.getDate()));
+ entry.addLink(alert.getAddress());
+ entry.setPublished(dateFormatter.parse(alert.getDate()));
- entries.add(entry);
+ feed.addEntry(entry);
}
} catch(Exception ex) {
System.err.println("Exception " + ex.toString());
}
- feed.setEntries(entries);
-
- return (Feed)feed.createWireFeed("atom_1.0");
+ return feed;
}
- /**
- * @see org.apache.tuscany.sca.binding.feed.Collection#delete(java.lang.String)
- */
public void delete(String id) throws NotFoundException {
}
- /**
- * @see org.apache.tuscany.sca.binding.feed.Collection#get(java.lang.String)
- */
public Entry get(String id) throws NotFoundException {
return null;
}
- /**
- * @see org.apache.tuscany.sca.binding.feed.Collection#post(com.sun.syndication.feed.atom.Entry)
- */
public Entry post(Entry entry) {
return null;
}
- /**
- * @see org.apache.tuscany.sca.binding.feed.Collection#postMedia(java.lang.String, java.lang.String, java.lang.String, java.io.InputStream)
- */
- public Entry postMedia(String title, String slug, String contentType, InputStream media) {
- return null;
- }
-
- /**
- * @see org.apache.tuscany.sca.binding.feed.Collection#put(java.lang.String, com.sun.syndication.feed.atom.Entry)
- */
public void put(String id, Entry entry) throws NotFoundException {
}
- /**
- * @see org.apache.tuscany.sca.binding.feed.Collection#putMedia(java.lang.String, java.lang.String, java.io.InputStream)
- */
- public Entry putMedia(String id, String contentType, InputStream media) throws NotFoundException {
- return null;
- }
}
Modified: incubator/tuscany/branches/sca-java-1.2/demos/bigbank/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/demos/bigbank/pom.xml?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/demos/bigbank/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.2/demos/bigbank/pom.xml Fri Mar 21 18:25:20 2008
@@ -44,6 +44,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-data-api</artifactId>
+ <version>2.0-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
<version>1.5.3</version>
@@ -57,13 +63,14 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <artifactId>tuscany-binding-atom-abdera</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
Modified: incubator/tuscany/branches/sca-java-1.2/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java Fri Mar 21 18:25:20 2008
@@ -18,77 +18,53 @@
*/
package bigbank.account.feed;
-import java.util.Collections;
-
-import org.apache.tuscany.sca.binding.feed.collection.Collection;
+import org.apache.tuscany.sca.implementation.data.collection.Collection;
+import org.apache.tuscany.sca.implementation.data.collection.Entry;
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
import bigbank.account.AccountService;
-import com.sun.syndication.feed.atom.Content;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Feed;
-import com.sun.syndication.feed.atom.Link;
-
/**
* @version $$Rev$$ $$Date$$
*/
@Service(Collection.class)
-public class AccountFeedImpl implements Collection {
+public class AccountFeedImpl implements Collection<String, String> {
@Reference
protected AccountService accountService;
- @SuppressWarnings("unchecked")
- public com.sun.syndication.feed.atom.Feed getFeed() {
-
- // Create a new Feed
- Feed feed = new Feed();
- feed.setId("accounts");
- feed.setTitle("Account Report Feed");
- Content subtitle = new Content();
- subtitle.setValue("This is a sample feed");
- feed.setSubtitle(subtitle);
- Link link = new Link();
- link.setHref("http://incubator.apache.org/tuscany");
- feed.getAlternateLinks().add(link);
+ public Entry<String, String>[] getAll() {
// Add the Account report entry
- Entry entry = get("1234");
- feed.getEntries().add(entry);
-
- return feed;
- }
+ String report = get("1234");
+ Entry<String, String> entry = new Entry<String, String>("1234", report);
- public void delete(String id) {
+ return new Entry[] { entry } ;
}
- public Entry get(String id) {
+ public String get(String id) {
// Get the account report for the specified customer ID
double balance = accountService.getAccountReport(id);
- String value = Double.toString(balance);
+ String report = Double.toString(balance);
- Entry entry = new Entry();
- entry.setId("account-" + id);
- entry.setTitle("Account Report Entry");
- Content summary = new Content();
- summary.setType(Content.HTML);
- summary.setValue("This is your account report: <b>" + value + "</b>");
- entry.setSummary(summary);
- Content content = new Content();
- content.setValue(value);
- entry.setContents(Collections.singletonList(content));
- return entry;
+ return report;
}
- public Entry post(Entry entry) {
+ public void delete(String key) throws NotFoundException {
+ }
+
+ public String post(String key, String item) {
return null;
}
- public void put(String id, Entry entry) {
+ public void put(String key, String item) throws NotFoundException {
}
+ public Entry<String, String>[] query(String queryString) {
+ return null;
+ }
}
Modified: incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/pom.xml?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/pom.xml Fri Mar 21 18:25:20 2008
@@ -43,6 +43,12 @@
<version>1.2-incubating-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-data-api</artifactId>
+ <version>2.0-incubating-SNAPSHOT</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-core</artifactId>
@@ -57,8 +63,9 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
+ <artifactId>tuscany-binding-atom-abdera</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
Modified: incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/feed/AccountFeedImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/feed/AccountFeedImpl.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/feed/AccountFeedImpl.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/feed/AccountFeedImpl.java Fri Mar 21 18:25:20 2008
@@ -1,94 +1,70 @@
-/*
- * 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 bigbank.account.feed;
-
-import java.util.Collections;
-
-import org.apache.tuscany.sca.binding.feed.collection.Collection;
-import org.osoa.sca.annotations.Reference;
-import org.osoa.sca.annotations.Service;
-
-import bigbank.account.AccountService;
-
-import com.sun.syndication.feed.atom.Content;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Feed;
-import com.sun.syndication.feed.atom.Link;
-
-/**
- * @version $$Rev: 592280 $$ $$Date: 2007-11-06 10:29:48 +0530 (Tue, 06 Nov 2007) $$
- */
-
-@Service(Collection.class)
-public class AccountFeedImpl implements Collection {
-
- @Reference
- protected AccountService accountService;
-
- @SuppressWarnings("unchecked")
- public com.sun.syndication.feed.atom.Feed getFeed() {
-
- // Create a new Feed
- Feed feed = new Feed();
- feed.setId("accounts");
- feed.setTitle("Account Report Feed");
- Content subtitle = new Content();
- subtitle.setValue("This is a sample feed");
- feed.setSubtitle(subtitle);
- Link link = new Link();
- link.setHref("http://incubator.apache.org/tuscany");
- feed.getAlternateLinks().add(link);
-
- // Add the Account report entry
- Entry entry = get("1234");
- feed.getEntries().add(entry);
-
- return feed;
- }
-
- public void delete(String id) {
- }
-
- public Entry get(String id) {
-
- // Get the account report for the specified customer ID
- double balance = accountService.getAccountReport(id);
- String value = Double.toString(balance);
-
- Entry entry = new Entry();
- entry.setId("account-" + id);
- entry.setTitle("Account Report Entry");
- Content summary = new Content();
- summary.setType(Content.HTML);
- summary.setValue("This is your account report: <b>" + value + "</b>");
- entry.setSummary(summary);
- Content content = new Content();
- content.setValue(value);
- entry.setContents(Collections.singletonList(content));
- return entry;
- }
-
- public Entry post(Entry entry) {
- return null;
- }
-
- public void put(String id, Entry entry) {
- }
-
-}
+/*
+ * 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 bigbank.account.feed;
+
+import org.apache.tuscany.sca.implementation.data.collection.Collection;
+import org.apache.tuscany.sca.implementation.data.collection.Entry;
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+import bigbank.account.AccountService;
+
+/**
+ * @version $$Rev: 635617 $$ $$Date: 2008-03-10 10:44:54 -0700 (Mon, 10 Mar 2008) $$
+ */
+
+@Service(Collection.class)
+public class AccountFeedImpl implements Collection<String, String> {
+
+ @Reference
+ protected AccountService accountService;
+
+ public Entry<String, String>[] getAll() {
+
+ // Add the Account report entry
+ String report = get("1234");
+ Entry<String, String> entry = new Entry<String, String>("1234", report);
+
+ return new Entry[] { entry } ;
+ }
+
+ public String get(String id) {
+
+ // Get the account report for the specified customer ID
+ double balance = accountService.getAccountReport(id);
+ String report = Double.toString(balance);
+
+ return report;
+ }
+
+ public void delete(String key) throws NotFoundException {
+ }
+
+ public String post(String key, String item) {
+ return null;
+ }
+
+ public void put(String key, String item) throws NotFoundException {
+ }
+
+ public Entry<String, String>[] query(String queryString) {
+ return null;
+ }
+}
Modified: incubator/tuscany/branches/sca-java-1.2/demos/xml-bigbank/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/demos/xml-bigbank/pom.xml?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/demos/xml-bigbank/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.2/demos/xml-bigbank/pom.xml Fri Mar 21 18:25:20 2008
@@ -53,7 +53,7 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
+ <artifactId>tuscany-binding-atom-abdera</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
Modified: incubator/tuscany/branches/sca-java-1.2/distribution/bundle/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/distribution/bundle/pom.xml?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/distribution/bundle/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.2/distribution/bundle/pom.xml Fri Mar 21 18:25:20 2008
@@ -49,11 +49,6 @@
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
- <version>${pom.version}</version>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
<artifactId>tuscany-binding-atom-abdera</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: incubator/tuscany/branches/sca-java-1.2/distribution/manifest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/distribution/manifest/pom.xml?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/distribution/manifest/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.2/distribution/manifest/pom.xml Fri Mar 21 18:25:20 2008
@@ -57,11 +57,6 @@
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
- <version>${pom.version}</version>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
<artifactId>tuscany-binding-atom</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java Fri Mar 21 18:25:20 2008
@@ -25,6 +25,7 @@
import org.apache.abdera.model.Document;
import org.apache.abdera.model.Entry;
import org.apache.abdera.model.Feed;
+import org.apache.abdera.parser.ParserOptions;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.DeleteMethod;
import org.apache.commons.httpclient.methods.GetMethod;
@@ -103,7 +104,8 @@
} catch (Exception e) {
msg.setFaultBody(new ServiceRuntimeException(e));
} finally {
- getMethod.releaseConnection();
+ // Will be released by the abdera parser
+ //getMethod.releaseConnection();
}
return msg;
@@ -155,7 +157,8 @@
} catch (Exception e) {
msg.setFaultBody(new ServiceRuntimeException(e));
} finally {
- postMethod.releaseConnection();
+ // Will be released by the abdera parser
+ //postMethod.releaseConnection();
}
return msg;
@@ -212,7 +215,8 @@
} catch (Exception e) {
msg.setFaultBody(new ServiceRuntimeException(e));
} finally {
- putMethod.releaseConnection();
+ // Will be released by the abdera parser
+ //putMethod.releaseConnection();
}
return msg;
@@ -298,7 +302,8 @@
} catch (Exception e) {
msg.setFaultBody(new ServiceRuntimeException(e));
} finally {
- getMethod.releaseConnection();
+ // Will be released by the abdera parser
+ //getMethod.releaseConnection();
}
return msg;
Modified: incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/pom.xml?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/pom.xml Fri Mar 21 18:25:20 2008
@@ -95,9 +95,9 @@
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
+ <artifactId>tuscany-binding-atom-abdera</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
- <scope>compile</scope>
+ <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
Modified: incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/modules/implementation-data-xml/src/test/java/org/apache/tuscany/sca/implementation/data/companyFeed/CompanyFeed.java Fri Mar 21 18:25:20 2008
@@ -19,83 +19,44 @@
package org.apache.tuscany.sca.implementation.data.companyFeed;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.tuscany.sca.binding.feed.collection.Collection;
-import org.apache.tuscany.sca.binding.feed.collection.NotFoundException;
import org.apache.tuscany.sca.implementation.data.DATA;
+import org.apache.tuscany.sca.implementation.data.collection.Collection;
+import org.apache.tuscany.sca.implementation.data.collection.Entry;
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
import org.osoa.sca.annotations.Reference;
-import com.sun.syndication.feed.atom.Content;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Feed;
-import com.sun.syndication.feed.atom.Link;
-import com.sun.syndication.feed.atom.Person;
import commonj.sdo.DataObject;
-public class CompanyFeed implements Collection {
+public class CompanyFeed implements Collection<String, DataObject> {
@Reference
protected DATA dataService;
- public Feed getFeed() {
-
- // Create a new Feed
- Feed feed = new Feed();
- feed.setTitle("Company Feed");
- Content subtitle = new Content();
- subtitle.setValue("A sample company feed");
- feed.setSubtitle(subtitle);
- Person author = new Person();
- author.setName("anonymous");
- feed.setAuthors(Collections.singletonList(author));
- Link link = new Link();
- link.setHref("http://incubator.apache.org/tuscany");
- feed.setAlternateLinks(Collections.singletonList(link));
-
- return feed;
+ public Entry<String, DataObject>[] getAll() {
+ return null;
}
- public Entry get(String id) throws NotFoundException{
+ public DataObject get(String id) throws NotFoundException{
DataObject data = null;//dataService.get(id);
if(data == null) {
throw new NotFoundException();
+ } else {
+ return data;
}
-
- Entry entry = new Entry();
- entry.setId(id);
- entry.setTitle(data.getString("name"));
- List<Link> links = new ArrayList<Link>();
- Link link = new Link();
- link.setRel("edit");
- link.setHref("entry/" + id);
- links.add(link);
- entry.setOtherLinks(links);
-
- links = new ArrayList<Link>();
- link = new Link();
- link.setRel("alternate");
- link.setHref("entry/" + id);
- links.add(link);
- entry.setAlternateLinks(links);
-
- entry.setCreated(new Date());
-
- return entry;
}
public void delete(String id) throws NotFoundException {
}
- public Entry post(Entry entry) {
+ public String post(String key, DataObject item) {
return null;
}
-
- public void put(String id, Entry entry) throws NotFoundException {
+
+ public void put(String key, DataObject item) throws NotFoundException {
+ }
+
+ public Entry<String, DataObject>[] query(String queryString) {
+ return null;
}
-
}
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/pom.xml?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/pom.xml Fri Mar 21 18:25:20 2008
@@ -45,17 +45,22 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <artifactId>tuscany-binding-rss-rome</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
- <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
+ <artifactId>tuscany-binding-atom-abdera</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-incubating-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
<!-- exclude stax 1.0.1 as we're also pulling in javax\xml\stream\stax-api\1.0-2 -->
<dependency>
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/AggregatorImpl.java Fri Mar 21 18:25:20 2008
@@ -18,18 +18,27 @@
*/
package feed;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.apache.tuscany.sca.binding.feed.collection.NotFoundException;
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Person;
+import org.apache.abdera.parser.Parser;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
-import com.sun.syndication.feed.atom.Content;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Link;
-import com.sun.syndication.feed.atom.Person;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.io.SyndFeedOutput;
/**
* Implementation of an SCA component that aggregates several
@@ -37,12 +46,18 @@
*
* @version $Rev$ $Date$
*/
-public class AggregatorImpl implements org.apache.tuscany.sca.binding.feed.collection.Collection {
+public class AggregatorImpl implements org.apache.tuscany.sca.binding.atom.collection.Collection {
- @Reference
- public org.apache.tuscany.sca.binding.feed.collection.Collection feed1;
- @Reference
- public org.apache.tuscany.sca.binding.feed.collection.Collection feed2;
+ @Reference(required = false)
+ public Collection atomFeed1;
+ @Reference(required = false)
+ public Collection atomFeed2;
+
+ @Reference(required = false)
+ public org.apache.tuscany.sca.binding.rss.collection.Collection rssFeed1;
+ @Reference(required = false)
+ public org.apache.tuscany.sca.binding.rss.collection.Collection rssFeed2;
+
@Reference(required = false)
public Sort sort;
@@ -52,33 +67,52 @@
public String feedDescription = "Anonymous Aggregated Feed";
@Property
public String feedAuthor = "anonymous";
-
- @SuppressWarnings("unchecked")
- public com.sun.syndication.feed.atom.Feed getFeed() {
+
+ public Feed getFeed() {
// Create a new Feed
- com.sun.syndication.feed.atom.Feed feed = new com.sun.syndication.feed.atom.Feed();
+ Factory factory = Abdera.getNewFactory();
+ Feed feed = factory.newFeed();
feed.setTitle(feedTitle);
- Content subtitle = new Content();
- subtitle.setValue(feedDescription);
- feed.setSubtitle(subtitle);
- Person author = new Person();
+ feed.setSubtitle(feedDescription);
+ Person author = factory.newAuthor();
author.setName(feedAuthor);
- feed.setAuthors(Collections.singletonList(author));
- Link link = new Link();
- link.setHref("http://incubator.apache.org/tuscany");
- feed.getAlternateLinks().add(link);
+ feed.addAuthor(author);
+ feed.addLink("http://incubator.apache.org/tuscany", "alternate");
- // Aggregate entries from feed1 and feed2
+ // Aggregate entries from atomFeed1, atomFeed2, rssFeed1 and rssFeed2
List<Entry> entries = new ArrayList<Entry>();
- entries.addAll(feed1.getFeed().getEntries());
- entries.addAll(feed2.getFeed().getEntries());
+ if (atomFeed1 != null) {
+ try {
+ entries.addAll(atomFeed1.getFeed().getEntries());
+ } catch (Exception e) {}
+ }
+ if (atomFeed2 != null) {
+ try {
+ entries.addAll(atomFeed2.getFeed().getEntries());
+ } catch (Exception e) {}
+ }
+ if (rssFeed1 != null) {
+ try {
+ entries.addAll(atomFeed(rssFeed1.getFeed()).getEntries());
+ } catch (Exception e) {}
+ }
+ if (rssFeed2 != null) {
+ try {
+ entries.addAll(atomFeed(rssFeed2.getFeed()).getEntries());
+ } catch (Exception e) {}
+ }
// Sort entries by published date
- if (sort != null)
- feed.setEntries(sort.sort(entries));
- else
- feed.setEntries(entries);
+ if (sort != null) {
+ entries = sort.sort(entries);
+ }
+
+ // Add the entries to the new feed
+ for (Entry entry: entries) {
+ feed.addEntry(entry);
+ }
+
return feed;
}
@@ -96,4 +130,26 @@
public void put(String id, Entry entry) throws NotFoundException {
}
+ /**
+ * Convert a ROME feed to an Abdera feed.
+ *
+ * @param romeFeed
+ * @return
+ */
+ private static Feed atomFeed(com.sun.syndication.feed.atom.Feed romeFeed) {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ SyndFeed syndFeed = new SyndFeedImpl(romeFeed);
+ syndFeed.setFeedType("atom_1.0");
+ SyndFeedOutput syndOutput = new SyndFeedOutput();
+ try {
+ syndOutput.output(syndFeed, new OutputStreamWriter(bos));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ Parser parser = Abdera.getNewParser();
+ Document<Feed> document = parser.parse(new ByteArrayInputStream(bos.toByteArray()));
+
+ return document.getRoot();
+ }
}
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/Sort.java Fri Mar 21 18:25:20 2008
@@ -20,7 +20,7 @@
import java.util.List;
-import com.sun.syndication.feed.atom.Entry;
+import org.apache.abdera.model.Entry;
/**
* The Sort service business interface.
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/java/feed/SortImpl.java Fri Mar 21 18:25:20 2008
@@ -23,9 +23,8 @@
import java.util.Date;
import java.util.List;
+import org.apache.abdera.model.Entry;
import org.osoa.sca.annotations.Property;
-
-import com.sun.syndication.feed.atom.Entry;
/**
* Implementation of a Feed Sort service component.
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator-webapp/src/main/resources/FeedAggregator.composite Fri Mar 21 18:25:20 2008
@@ -23,7 +23,7 @@
name="FeedAggregator">
<service name="rssSample" promote="RssAggregator">
- <tuscany:binding.rss uri="http://localhost:8083/rssAggregator"/>
+ <tuscany:binding.atom uri="http://localhost:8083/rssAggregator"/>
</service>
<service name="atomSample" promote="AtomAggregator">
<tuscany:binding.atom uri="http://localhost:8083/atomAggregator"/>
@@ -31,14 +31,14 @@
<component name="RssAggregator">
<implementation.java class="feed.AggregatorImpl"/>
- <reference name="feed1">
+ <reference name="rssfeed1">
<tuscany:binding.rss uri="http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml"/>
</reference>
- <reference name="feed2">
+ <reference name="rssFeed2">
<tuscany:binding.rss uri="http://www.engadget.com/rss.xml"/>
</reference>
<reference name="sort" target="Sort"/>
- <property name="feedTitle">Rss Sample</property>
+ <property name="feedTitle">RSS Aggregator Sample</property>
</component>
<component name="Sort">
<implementation.java class="feed.SortImpl"/>
@@ -47,14 +47,14 @@
<component name="AtomAggregator">
<implementation.java class="feed.AggregatorImpl"/>
- <reference name="sort" target="Sort"/>
- <reference name="feed1">
+ <reference name="sort" target="Sort"/>
+ <reference name="atomFeed1">
<tuscany:binding.atom uri="http://www.oreillynet.com/pub/feed/1"/>
</reference>
- <reference name="feed2">
- <tuscany:binding.atom uri="http://www.apachenews.org/atom.xml"/>
+ <reference name="atomFeed2">
+ <tuscany:binding.atom uri="http://feeds.feedburner.com/blogspot/Dcni?format=xml"/>
</reference>
- <property name="feedTitle">Atom Sample</property>
+ <property name="feedTitle">Atom Aggregator Sample</property>
</component>
-</composite>
+</composite>
\ No newline at end of file
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/pom.xml?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/pom.xml Fri Mar 21 18:25:20 2008
@@ -44,16 +44,21 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <artifactId>tuscany-binding-rss-rome</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
- <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-binding-feed</artifactId>
+ <artifactId>tuscany-binding-atom-abdera</artifactId>
<version>1.2-incubating-SNAPSHOT</version>
- <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-incubating-SNAPSHOT</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java Fri Mar 21 18:25:20 2008
@@ -18,18 +18,27 @@
*/
package feed;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import org.apache.tuscany.sca.binding.feed.collection.NotFoundException;
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Person;
+import org.apache.abdera.parser.Parser;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
import org.osoa.sca.annotations.Property;
import org.osoa.sca.annotations.Reference;
-import com.sun.syndication.feed.atom.Content;
-import com.sun.syndication.feed.atom.Entry;
-import com.sun.syndication.feed.atom.Link;
-import com.sun.syndication.feed.atom.Person;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.io.SyndFeedOutput;
/**
* Implementation of an SCA component that aggregates several
@@ -37,12 +46,18 @@
*
* @version $Rev$ $Date$
*/
-public class AggregatorImpl implements org.apache.tuscany.sca.binding.feed.collection.Collection {
+public class AggregatorImpl implements org.apache.tuscany.sca.binding.atom.collection.Collection {
- @Reference
- public org.apache.tuscany.sca.binding.feed.collection.Collection feed1;
- @Reference
- public org.apache.tuscany.sca.binding.feed.collection.Collection feed2;
+ @Reference(required = false)
+ public Collection atomFeed1;
+ @Reference(required = false)
+ public Collection atomFeed2;
+
+ @Reference(required = false)
+ public org.apache.tuscany.sca.binding.rss.collection.Collection rssFeed1;
+ @Reference(required = false)
+ public org.apache.tuscany.sca.binding.rss.collection.Collection rssFeed2;
+
@Reference(required = false)
public Sort sort;
@@ -52,33 +67,52 @@
public String feedDescription = "Anonymous Aggregated Feed";
@Property
public String feedAuthor = "anonymous";
-
- @SuppressWarnings("unchecked")
- public com.sun.syndication.feed.atom.Feed getFeed() {
+
+ public Feed getFeed() {
// Create a new Feed
- com.sun.syndication.feed.atom.Feed feed = new com.sun.syndication.feed.atom.Feed();
+ Factory factory = Abdera.getNewFactory();
+ Feed feed = factory.newFeed();
feed.setTitle(feedTitle);
- Content subtitle = new Content();
- subtitle.setValue(feedDescription);
- feed.setSubtitle(subtitle);
- Person author = new Person();
+ feed.setSubtitle(feedDescription);
+ Person author = factory.newAuthor();
author.setName(feedAuthor);
- feed.setAuthors(Collections.singletonList(author));
- Link link = new Link();
- link.setHref("http://incubator.apache.org/tuscany");
- feed.getAlternateLinks().add(link);
+ feed.addAuthor(author);
+ feed.addLink("http://incubator.apache.org/tuscany", "alternate");
- // Aggregate entries from feed1 and feed2
+ // Aggregate entries from atomFeed1, atomFeed2, rssFeed1 and rssFeed2
List<Entry> entries = new ArrayList<Entry>();
- entries.addAll(feed1.getFeed().getEntries());
- entries.addAll(feed2.getFeed().getEntries());
+ if (atomFeed1 != null) {
+ try {
+ entries.addAll(atomFeed1.getFeed().getEntries());
+ } catch (Exception e) {}
+ }
+ if (atomFeed2 != null) {
+ try {
+ entries.addAll(atomFeed2.getFeed().getEntries());
+ } catch (Exception e) {}
+ }
+ if (rssFeed1 != null) {
+ try {
+ entries.addAll(atomFeed(rssFeed1.getFeed()).getEntries());
+ } catch (Exception e) {}
+ }
+ if (rssFeed2 != null) {
+ try {
+ entries.addAll(atomFeed(rssFeed2.getFeed()).getEntries());
+ } catch (Exception e) {}
+ }
// Sort entries by published date
- if (sort != null)
- feed.setEntries(sort.sort(entries));
- else
- feed.setEntries(entries);
+ if (sort != null) {
+ entries = sort.sort(entries);
+ }
+
+ // Add the entries to the new feed
+ for (Entry entry: entries) {
+ feed.addEntry(entry);
+ }
+
return feed;
}
@@ -96,4 +130,26 @@
public void put(String id, Entry entry) throws NotFoundException {
}
+ /**
+ * Convert a ROME feed to an Abdera feed.
+ *
+ * @param romeFeed
+ * @return
+ */
+ private static Feed atomFeed(com.sun.syndication.feed.atom.Feed romeFeed) {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ SyndFeed syndFeed = new SyndFeedImpl(romeFeed);
+ syndFeed.setFeedType("atom_1.0");
+ SyndFeedOutput syndOutput = new SyndFeedOutput();
+ try {
+ syndOutput.output(syndFeed, new OutputStreamWriter(bos));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ Parser parser = Abdera.getNewParser();
+ Document<Feed> document = parser.parse(new ByteArrayInputStream(bos.toByteArray()));
+
+ return document.getRoot();
+ }
}
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/Sort.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/Sort.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/Sort.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/Sort.java Fri Mar 21 18:25:20 2008
@@ -20,7 +20,7 @@
import java.util.List;
-import com.sun.syndication.feed.atom.Entry;
+import org.apache.abdera.model.Entry;
/**
* The Sort service business interface.
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/SortImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/SortImpl.java?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/SortImpl.java (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/java/feed/SortImpl.java Fri Mar 21 18:25:20 2008
@@ -23,9 +23,8 @@
import java.util.Date;
import java.util.List;
+import org.apache.abdera.model.Entry;
import org.osoa.sca.annotations.Property;
-
-import com.sun.syndication.feed.atom.Entry;
/**
* Implementation of a Feed Sort service component.
Modified: incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/resources/FeedAggregator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/resources/FeedAggregator.composite?rev=639933&r1=639932&r2=639933&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/resources/FeedAggregator.composite (original)
+++ incubator/tuscany/branches/sca-java-1.2/samples/feed-aggregator/src/main/resources/FeedAggregator.composite Fri Mar 21 18:25:20 2008
@@ -23,7 +23,7 @@
name="FeedAggregator">
<service name="rssSample" promote="RssAggregator">
- <tuscany:binding.rss uri="http://localhost:8083/rssAggregator"/>
+ <tuscany:binding.atom uri="http://localhost:8083/rssAggregator"/>
</service>
<service name="atomSample" promote="AtomAggregator">
<tuscany:binding.atom uri="http://localhost:8083/atomAggregator"/>
@@ -31,14 +31,14 @@
<component name="RssAggregator">
<implementation.java class="feed.AggregatorImpl"/>
- <reference name="feed1">
+ <reference name="rssfeed1">
<tuscany:binding.rss uri="http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml"/>
</reference>
- <reference name="feed2">
+ <reference name="rssFeed2">
<tuscany:binding.rss uri="http://www.engadget.com/rss.xml"/>
</reference>
<reference name="sort" target="Sort"/>
- <property name="feedTitle">Rss Sample</property>
+ <property name="feedTitle">RSS Aggregator Sample</property>
</component>
<component name="Sort">
<implementation.java class="feed.SortImpl"/>
@@ -48,13 +48,13 @@
<component name="AtomAggregator">
<implementation.java class="feed.AggregatorImpl"/>
<reference name="sort" target="Sort"/>
- <reference name="feed1">
+ <reference name="atomFeed1">
<tuscany:binding.atom uri="http://www.oreillynet.com/pub/feed/1"/>
</reference>
- <reference name="feed2">
- <tuscany:binding.atom uri="http://www.apachenews.org/atom.xml"/>
+ <reference name="atomFeed2">
+ <tuscany:binding.atom uri="http://feeds.feedburner.com/blogspot/Dcni?format=xml"/>
</reference>
- <property name="feedTitle">Atom Sample</property>
+ <property name="feedTitle">Atom Aggregator Sample</property>
</component>
</composite>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org