abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1173209 [28/49] - in /abdera/abdera2: ./ .settings/ activities/ activities/src/ activities/src/main/ activities/src/main/java/ activities/src/main/java/org/ activities/src/main/java/org/apache/ activities/src/main/java/org/apache/abdera2/ ...
Date Tue, 20 Sep 2011 15:57:20 GMT
Added: abdera/abdera2/etc/notice-supplements.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/etc/notice-supplements.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/etc/notice-supplements.xml (added)
+++ abdera/abdera2/etc/notice-supplements.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+<supplementalDataModels>
+  <supplement>
+    <project>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <name>Servlet API</name>
+      <organization>
+        <name>Sun Microsystems</name>
+        <url>http://www.sun.com/</url>
+      </organization>
+      <licenses>
+        <license>
+          <name>COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0</name>
+          <url>http://www.sun.com/cddl/cddl.html</url>
+        </license>
+      </licenses>
+    </project>
+  </supplement>
+  <supplement>
+    <project>
+      <groupId>commons-beanutils</groupId>
+      <artifactId>commons-beanutils</artifactId>
+      <name>Apache Commons Beanutils</name>
+      <organization>
+        <name>The Apache Software Foundation</name>
+        <url>http://www.apache.org</url>
+      </organization>
+      <licenses>
+        <license>
+          <name>The Apache Software License, Version 2.0</name>
+          <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+        </license>
+      </licenses>
+    </project>
+  </supplement>
+  <supplement>
+    <project>
+      <groupId>org.apache.ibatis</groupId>
+      <artifactId>ibatis-sqlmap</artifactId>
+      <name>Apache Ibatis</name>
+      <organization>
+        <name>The Apache Software Foundation</name>
+        <url>http://www.apache.org/</url>
+      </organization>
+      <licenses>
+        <license>
+          <name>The Apache Software License, Version 2.0</name>
+          <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+        </license>
+      </licenses>
+    </project>
+  </supplement>
+  <supplement>
+    <project>
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-core</artifactId>
+      <name>Apache Lucene</name>
+      <organization>
+        <name>The Apache Software Foundation</name>
+        <url>http://www.apache.org/</url>
+      </organization>
+      <licenses>
+        <license>
+          <name>The Apache Software License, Version 2.0</name>
+          <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+        </license>
+      </licenses>
+    </project>
+  </supplement>
+  <supplement>
+    <project>
+      <groupId>xalan</groupId>
+      <artifactId>xalan</artifactId>
+      <name>Apache Xalan-Java</name>
+      <organization>
+        <name>The Apache Software Foundation</name>
+        <url>http://www.apache.org/</url>
+      </organization>
+      <licenses>
+        <license>
+          <name>The Apache Software License, Version 2.0</name>
+          <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+        </license>
+      </licenses>
+    </project>
+  </supplement>
+  <supplement>
+    <project>
+      <groupId>xml-security</groupId>
+      <artifactId>xmlsec</artifactId>
+      <name>XML Security</name>
+      <organization>
+        <name>The Apache Software Foundation</name>
+        <url>http://www.apache.org/</url>
+      </organization>
+      <licenses>
+        <license>
+          <name>The Apache Software License, Version 2.0</name>
+          <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+        </license>
+      </licenses>
+    </project>
+  </supplement>
+  <supplement>
+    <project>
+      <groupId>xml-apis</groupId>
+      <artifactId>xml-apis</artifactId>
+      <name>XML APIs</name>
+      <organization>
+        <name>The Apache Software Foundation</name>
+        <url>http://www.apache.org</url>
+      </organization>
+      <licenses>
+        <license>
+          <name>The Apache Software License, Version 2.0</name>
+          <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+        </license>
+      </licenses>
+    </project>
+  </supplement>
+  <supplement>
+    <project>
+      <groupId>bouncycastle</groupId>
+      <artifactId>bcprov-jdk15</artifactId>
+      <name>Bouncy Castle Crypto APIs for Java</name>
+      <organization>
+        <name>The Legion of the Bouncy Castle</name>
+        <url>http://www.bouncycastle.org</url>
+      </organization>
+      <licenses>
+        <license>
+          <name>Bouncy Castle License</name>
+          <url>http://www.bouncycastle.org/licence.html</url>
+        </license>
+      </licenses>
+    </project>
+  </supplement>
+  <supplement>
+    <project>
+      <groupId>nu.validator.htmlparser</groupId>
+      <artifactId>htmlparser</artifactId>
+      <name>The Validator.nu HTML Parser</name>
+      <organization>
+        <name>Validator.nu</name>
+        <url>http://about.validator.nu/htmlparser</url>
+      </organization>
+      <licenses>
+        <license>
+          <name>Htmlparser License</name>
+          <url>http://about.validator.nu/htmlparser</url>
+        </license>
+      </licenses>
+    </project>
+  </supplement>
+    <supplement>
+      <project>
+        <groupId>jaxen</groupId>
+        <artifactId>jaxen</artifactId>
+        <name>Jaxen</name>
+        <organization>
+          <name>The Werken Company</name>
+          <url>http://jaxen.codehaus.org</url>
+        </organization>
+        <licenses>
+          <license>
+            <name>Jaxen License</name>
+            <url>http://jaxen.codehaus.org/license.html</url>
+          </license>
+        </licenses>
+      </project>
+  </supplement>
+  
+    <supplement>
+      <project>
+        <groupId>org.apache.ws.commons.axiom</groupId>
+        <artifactId>axiom-impl</artifactId>
+        <name>Axiom Impl</name>
+        <organization>
+          <name>The Apache Software Foundation</name>
+          <url>http://www.apache.org/</url>
+        </organization>
+        <licenses>
+          <license>
+            <name>The Apache Software License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+          </license>
+        </licenses>
+      </project>
+  </supplement>
+</supplementalDataModels>

Propchange: abdera/abdera2/etc/notice-supplements.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: abdera/abdera2/etc/notice-supplements.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/pom.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/pom.xml (added)
+++ abdera/abdera2/examples/pom.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,78 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.abdera</groupId>
+    <artifactId>abdera</artifactId>
+    <version>1.2-SNAPSHOT</version>  
+  </parent>  
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>abdera-examples</artifactId>
+  <packaging>jar</packaging>
+  <name>Abdera Examples</name>
+  <version>1.2-SNAPSHOT</version>  
+  <description>Atom Specification Implementation Examples</description>
+
+  <properties>
+    <topDir>${basedir}/..</topDir>
+  </properties>
+  
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-client</artifactId>
+      <version>1.2-SNAPSHOT</version>  
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-server</artifactId>
+      <version>1.2-SNAPSHOT</version>  
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-extensions-main</artifactId>
+      <version>1.2-SNAPSHOT</version>  
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-extensions-serializer</artifactId>
+      <version>1.2-SNAPSHOT</version>  
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-extensions-gdata</artifactId>
+      <version>1.2-SNAPSHOT</version>  
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-extensions-geo</artifactId>
+      <version>1.2-SNAPSHOT</version>  
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-extensions-sharing</artifactId>
+      <version>1.2-SNAPSHOT</version>  
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-extensions-features</artifactId>
+      <version>1.2-SNAPSHOT</version>  
+    </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-security</artifactId>
+      <version>1.2-SNAPSHOT</version>  
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <version>${jetty.version}</version>  
+    </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Propchange: abdera/abdera2/examples/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,59 @@
+package org.apache.abdera2.examples.activities;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.activities.model.Verb;
+import org.apache.abdera2.activities.model.objects.PersonObject;
+
+public class Activities {
+
+  public static void main(String... args) throws Exception {
+    
+    // Simple Activities Example
+    
+    Activity activity = new Activity();
+    
+    activity.setActor("James");     // Subject
+    activity.setVerb(Verb.FOLLOW);  // Verb
+     
+                                    // Object
+    PersonObject person = new PersonObject();
+    person.setDisplayName("John Doe");
+    person.setProperty("email", "john.doe@example.org");
+    activity.setObject(person);
+    
+    activity.writeTo(System.out);
+    
+    System.out.println("\n\n\n");
+    
+    // Activity Stream
+    Collection<Activity> collection = new Collection<Activity>();
+    collection.addItem(activity);
+    
+    collection.writeTo(System.out);
+    
+    
+    System.out.println("\n\n\n");
+    
+    // Parsing example
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    collection.writeTo(out);
+    
+    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+    
+    collection = IO.get().readCollection(in, "UTF-8");
+    
+    for (Activity a : collection.getItems()) {
+      System.out.println(String.format("%s [%s] %s", 
+          a.getActor().getDisplayName(), 
+          a.getVerb(), 
+          a.getObject().getDisplayName()));
+    }
+    
+  }
+  
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ActivitiesServlet.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ActivitiesServlet.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ActivitiesServlet.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ActivitiesServlet.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,23 @@
+package org.apache.abdera2.examples.activities;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.annotation.WebInitParam;
+import org.apache.abdera2.common.protocol.servlet.AbderaServlet;
+
+@WebServlet(
+  urlPatterns="/*",
+  initParams={
+    @WebInitParam(
+      name="org.apache.abdera2.common.protocol.ServiceManager",
+      value="org.apache.abdera2.activities.protocol.ActivitiesServiceManager"
+    ),
+    @WebInitParam(
+      name="org.apache.abdera2.common.protocol.Provider", 
+      value="org.apache.abdera2.activities.protocol.basic.BasicProvider"
+    )
+  }
+)
+public class ActivitiesServlet
+  extends AbderaServlet {
+  private static final long serialVersionUID = -2969428720501378351L;
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ActivitiesServlet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,36 @@
+package org.apache.abdera2.examples.activities;
+
+import org.apache.abdera2.activities.extra.ExtendedEventObject;
+import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.activities.model.objects.PersonObject;
+import org.apache.abdera2.common.anno.Name;
+
+/**
+ * Quick example that shows how new object types can be
+ * created by extending the base object types.. in this
+ * case, we create a hypothetical representation of a 
+ * Google+ style "hangout" being hosted by user "james"
+ * with one other user ("joe") in attendance.
+ */
+public class ExtendingBaseObjectExample {
+
+  @SuppressWarnings("unchecked")
+  public static void main(String... args) throws Exception {
+
+    // Building an activity stream for a reading list
+    IO io = IO.get();
+    io.addObjectMapping(Hangout.class);
+    
+    Hangout hangout = new Hangout();
+    hangout.setHost(new PersonObject("james"));
+    hangout.getAttending(true).addItem(new PersonObject("joe"));
+
+    io.write(hangout,System.out,"UTF-8");
+  }
+
+  @Name("hangout")
+  public static class Hangout 
+    extends ExtendedEventObject {
+    private static final long serialVersionUID = -5466869609152673390L;
+  }
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtensionExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtensionExample.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtensionExample.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtensionExample.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,102 @@
+package org.apache.abdera2.examples.activities;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera2.activities.io.gson.AdaptedType;
+import org.apache.abdera2.activities.io.gson.Properties;
+import org.apache.abdera2.activities.io.gson.Property;
+import org.apache.abdera2.activities.io.gson.SimpleAdapter;
+import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.common.anno.Name;
+import org.apache.abdera2.common.http.EntityTag;
+
+public class ExtensionExample {
+
+  @SuppressWarnings("unchecked")
+  public static void main(String... args) throws Exception {
+    
+    // create the io with our custom type adapter
+    IO io = IO.get(new BarAdapter());
+    
+    // tell the serializer about our new object type
+    io.addObjectMapping(FooObject.class);
+    
+    FooObject foo = new FooObject();
+    foo.setETag(new EntityTag("test",true));
+    foo.setBar(new Bar("foobarbaz"));
+        
+    Map<Bar,String> map = new HashMap<Bar,String>();
+    map.put(new Bar("z"),"a");
+    map.put(new Bar("y"), "b");
+    foo.setProperty("map",map);
+    
+    // outputs: foo
+    System.out.println(foo.getObjectType());
+    
+    // outputs: {"etag":"W/\"test\"","map":{"y":"b","z":"a"},"bar":"foobarbaz","objectType":"foo"}
+    foo.writeTo(io,System.out);
+    
+    // now try reading it
+    StringReader sr = new StringReader(io.write(foo));
+    foo = io.readObject(sr);
+
+    System.out.println();
+    
+    // check to make sure the etag was deserialized properly
+    System.out.println(foo.getETag().getClass());
+    
+    System.out.println(foo.getBar().getClass());
+    
+    // map will deserialize as an asobject
+    System.out.println(foo.getProperty("map").getClass());
+    
+  }
+  
+  @Name("foo")  // the value of the objectType property
+  @Properties({
+    // tell the deserializer to map the etag property to the EntityTag class
+    @Property(name="etag",to=EntityTag.class),
+    @Property(name="bar",to=Bar.class)
+  })
+  public static class FooObject extends ASObject {
+    private static final long serialVersionUID = 3601006822295281310L;
+    public EntityTag getETag() {
+      return getProperty("etag");
+    }
+    public void setETag(EntityTag etag) {
+      setProperty("etag", etag);
+    }
+    public Bar getBar() {
+      return getProperty("bar");
+    }
+    public void setBar(Bar bar) {
+      setProperty("bar",bar);
+    }
+  }
+  
+  // Some new class that we want to use as a value.. need to tell 
+  // the serializer how to handle it!
+  public static class Bar {
+    private final String s;
+    public Bar(String s) {
+      this.s = s;
+    }
+    public String toString() {
+      return s;
+    }
+  }
+  
+  // The (de)serializer for the Bar class.. SimpleAdapter uses 
+  // toString to serialize.. other TypeAdapter implementations
+  // can use any strategy for serialization
+  @AdaptedType(Bar.class)
+  public static class BarAdapter 
+    extends SimpleAdapter<Bar> {
+    protected Bar deserialize(String v) {
+      return new Bar(v);
+    }
+  }
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtensionExample.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GeneratorStreamingExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GeneratorStreamingExample.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GeneratorStreamingExample.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GeneratorStreamingExample.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,83 @@
+package org.apache.abdera2.examples.activities;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.apache.abdera2.activities.model.ASBase;
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.activities.model.CollectionWriter;
+import org.apache.abdera2.activities.model.Generator;
+import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.activities.model.Verb;
+import org.apache.abdera2.activities.model.objects.PersonObject;
+import org.apache.abdera2.activities.model.objects.ServiceObject;
+
+/**
+ * Demonstrates the use of the Generator and CollectionWriter 
+ * utilities to produce activities using a template and stream
+ * those out into an Activity Stream Collection. 
+ */
+public class GeneratorStreamingExample {
+
+  public static void main(String... args) throws Exception {
+    
+    ByteArrayOutputStream out = 
+      new ByteArrayOutputStream();
+    
+    // Prepare the writer
+    IO io = IO.get();
+    CollectionWriter writer = 
+      io.getCollectionWriter(out, "UTF-8");
+    
+    // Output the collection header
+    ASBase header = new ASBase();
+    header.setProperty("title", "My Items");
+    header.setProperty("totalItems", 10);
+    writer.writeHeader(header);
+    
+    // Prepare the Activity template
+    Activity template = new Activity();
+    PersonObject person = new PersonObject();
+    person.setDisplayName("joe");
+    template.setActor(person);
+    template.setVerb(Verb.POST);
+    template.setProvider(
+      new ServiceObject("My Application"));
+    Generator<Activity> gen = 
+      template.newGenerator();
+    
+    // we can now use the Generator to produce 
+    // new Activities using the one we just 
+    // created as a template. It's values will
+    // be copied into the new object. Note, the 
+    // copies are NOT deep.. that is, if you 
+    // specify a List as one of the property
+    // values in the template, each instance 
+    // created will share a reference to that
+    // same list object, so if the list if modified,
+    // all copies generated will reference the 
+    // modified list
+    for (int n = 0; n < 10; n++) {
+      writer.writeObject(  // write out each object as we create it
+        gen.startNew()
+          .set("title", "A" + n)
+          .complete());
+    }
+    
+    // complete the writer.. very important.. always do this
+    // or the json generated by the writer will be malformed
+    writer.complete();
+    
+    // let's make sure we can read it
+    ByteArrayInputStream in = 
+      new ByteArrayInputStream(out.toByteArray());
+    Collection<Activity> col = io.readCollection(in, "UTF-8");
+    System.out.println(col.getProperty("title"));
+    System.out.println(col.getTotalItems());
+    for (Activity a : col.getItems()) {
+      System.out.println(a.getTitle() + "\t" + a.getVerb());
+    }
+  }
+  
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GeneratorStreamingExample.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GooglePlusExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GooglePlusExample.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GooglePlusExample.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GooglePlusExample.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,40 @@
+package org.apache.abdera2.examples.activities;
+
+import org.apache.abdera2.common.anno.Context;
+import org.apache.abdera2.common.anno.Param;
+import org.apache.abdera2.common.anno.URITemplate;
+
+import org.apache.abdera2.activities.client.ActivitiesClient;
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Collection;
+import static org.apache.abdera2.common.templates.Template.expandAnnotated;
+import static java.lang.System.out;
+import static java.lang.String.format;
+
+@URITemplate("https://www.googleapis.com/plus/v1/people/{userid}/activities/{collection}{?key}&fields={+fields}")
+@Context({
+  @Param(name="key",value="{your api key}"),
+  @Param(name="collection",value="public"),
+  @Param(name="fields",value="items/title")})
+public class GooglePlusExample   {
+  
+  public final String userid = "{user id}";
+    
+  public static void main(String... args) throws Exception {
+    ActivitiesClient cl = 
+      new ActivitiesClient();
+    try {
+      Collection<Activity> c = 
+        cl.getCollection(
+          expandAnnotated(
+            new GooglePlusExample()));
+      out.println(c.getProperty("title"));
+      int n = 1;
+      for (Activity a : c.getItems())
+        out.println(
+          format("%d. %s", n++, a.getTitle()));
+    } finally {      
+      cl.shutdown(); 
+    }
+  }
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GooglePlusExample.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MiscellaneousExamples.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MiscellaneousExamples.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MiscellaneousExamples.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MiscellaneousExamples.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,38 @@
+package org.apache.abdera2.examples.activities;
+
+import org.apache.abdera2.activities.extra.ASContext;
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.common.templates.Template;
+
+public class MiscellaneousExamples {
+
+  public static void main(String... args) throws Exception {
+    
+    // Working with URI Templates.. the Misc.ASContext 
+    // provides a URI Template Context implementation
+    // that wraps an Activity Streams object, making it 
+    // easier to construct IRI/URI's using properties
+    // contained within an activity stream. For instance,
+    // the Google+ API specifies a "nextPageToken" property
+    // within the root collection object that is used to
+    // construct the URL for the next page in a paged 
+    // collection of stream documents. Using Misc.ASContext,
+    // it's a simple matter to pull that out and construct
+    // the url for the next page.
+    
+    Collection<Activity> collection = 
+      new Collection<Activity>();
+    collection.setProperty("nextPageToken", "foo");
+    
+    Template template = 
+      new Template("http://example.org/stuff{?nextPageToken}");
+    
+    System.out.println(
+      template.expand(
+        new ASContext(collection)));
+    
+    
+  }
+  
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MiscellaneousExamples.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MyActivitiesAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MyActivitiesAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MyActivitiesAdapter.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MyActivitiesAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,165 @@
+package org.apache.abdera2.examples.activities;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.activities.protocol.basic.BasicAdapter;
+import org.apache.abdera2.activities.protocol.managed.FeedConfiguration;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.ResponseContextException;
+
+public class MyActivitiesAdapter extends BasicAdapter {
+
+    private static final String ERROR_INVALID_ENTRY = "No Such Entry in the Feed";
+
+    public static Logger logger = Logger.getLogger(MyActivitiesAdapter.class.getName());
+    protected List<Item> entries = new LinkedList<Item>();
+
+    private static class Item {
+      private final String key;
+      private ASObject value;
+      Item(String key, ASObject value) {
+        this.key = key;
+        this.value = value;
+      }
+      String getKey() {
+        return key;
+      }
+      ASObject getValue() {
+        return value;
+      }
+      void setValue(ASObject value) {
+        this.value = value;
+      }
+    }
+    
+    public MyActivitiesAdapter(FeedConfiguration config) {
+        super(config);
+    }
+
+    @Override
+    public Collection<ASObject> getCollection() throws Exception {
+        Collection<ASObject> col = createCollection();
+        
+        for (Item item : entries)
+          col.addItem(item.getValue());
+        return col;
+    }
+
+    @Override
+    public ASObject getItem(Object entryId) throws Exception {
+      ASObject ret = null;
+      for (Item item : entries)
+        if (item.getKey().equals(entryId.toString())) {
+          ret = item.getValue();
+          break;
+        }
+      return ret;
+    }
+
+    @Override
+    public ASObject createItem(ASObject object) throws Exception {
+        return createItem(object,-1);
+    }
+    
+    @Override
+    public ASObject createItem(ASObject object, int c) throws Exception {
+        setObjectIdIfNull(object);
+        logger.info("assigning id to Object: " + object.getId().toString());
+        String entryId = getObjectIdFromUri(object.getId().toString());
+        if (c != -1) entryId += c;
+        if (object.getUpdated() == null) {
+            object.setUpdated(new Date());
+        }
+        addEditLinkToObject(object);
+        storeObject(entryId, object);
+        logger.finest("returning this object from sampleadapter.createItem: " + object.toString());
+        return object;
+    }
+
+    @Override
+    public ASObject updateItem(Object entryId, ASObject object) throws Exception {
+        if (!deleteItem(entryId))
+            throw new Exception(ERROR_INVALID_ENTRY);
+        
+        if (object.getUpdated() == null) {
+            object.setUpdated(new Date());
+        }
+        addEditLinkToObject(object);
+        storeObject((String)entryId, object);
+        logger.finest("returning this entry from sampleadapter.updateEntry: " + object.toString());
+        return object;
+    }
+
+    @Override
+    public boolean deleteItem(Object entryId) throws Exception {
+      Item item = null;
+      for (Item i : entries) {
+        if (i.getKey().equals(entryId.toString())) {
+          item = i;
+          break;
+        }
+      }
+      if (item != null) {
+        entries.remove(item);
+        return true;
+      } else return false;
+    }
+
+    protected String getObjectIdFromUri(String uri) {
+        String[] segments = uri.split("/");
+        return segments[segments.length - 1];
+    }
+
+    protected void storeObject(String entryId, ASObject object) throws Exception {
+      Item item = null;
+      for (Item i : entries) {
+        if (i.getKey().equals(entryId)) {
+          item = i;
+          break;
+        }
+      }
+      if (item == null) { 
+        entries.add(0,new Item(entryId,object));
+      } else {
+        item.setValue(object);
+      }
+    }
+
+    @Override
+    public String getAuthor(RequestContext request) throws ResponseContextException {
+        return config.getFeedAuthor();
+    }
+
+    @Override
+    public String getId(RequestContext request) {
+        return config.getFeedId();
+    }
+
+    @Override
+    public String getTitle(RequestContext request) {
+        return config.getFeedTitle();
+    }
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MyActivitiesAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,63 @@
+package org.apache.abdera2.examples.activities;
+
+import org.apache.abdera2.activities.extra.BookObject;
+import org.apache.abdera2.activities.extra.Extra;
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.activities.model.Generator;
+import org.apache.abdera2.activities.model.IO;
+import org.apache.abdera2.activities.model.Verb;
+import org.apache.abdera2.activities.model.objects.PersonObject;
+
+/**
+ * Example that shows a simple practical use of an activity stream
+ * to represent a user activity on their reading list. For instance,
+ * the "save" verb can be used to indicate that a user has added a 
+ * book to their reading list, while the "read" verb can indicate 
+ * that the user has read a book from their reading list
+ */
+public class ReadingListExample {
+
+  public static void main(String... args) throws Exception {
+    
+    // Building an activity stream for a reading list
+    IO io = IO.get();
+    Extra.initExtras(io);
+    
+    Collection<Activity> stream = 
+      new Collection<Activity>();
+    
+    Activity template = 
+      new Activity();
+    PersonObject actor = 
+      new PersonObject("James");
+    template.setActor(actor);
+    Generator<Activity> gen = 
+      template.newGenerator();
+    
+    // Add a book we want to read
+    BookObject book1 = 
+      new BookObject("The Cat in the Hat");
+    stream.addItem(
+      gen.startNew()
+         .set("verb", Verb.SAVE)
+         .set("object", book1)
+         .set("format", Extra.EBOOK())
+         .complete());
+    
+    // Add a book we just finished
+    BookObject book2 =
+      new BookObject("Meditations on the Method");
+    book2.setAuthor(new PersonObject("Rene Descartes"));
+    stream.addItem(
+      gen.startNew()
+         .set("verb", Verb.READ)
+         .set("object", book2)
+         .set("format", Extra.HARDCOVER())
+         .complete());
+    
+    stream.writeTo(io,System.out);
+    
+  }
+  
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,54 @@
+package org.apache.abdera2.examples.activities;
+
+import org.apache.abdera2.activities.extra.Extra;
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Activity.Audience;
+import org.apache.abdera2.activities.model.objects.NoteObject;
+import org.apache.abdera2.activities.model.objects.PersonObject;
+
+public class RepliesAndTargetingExample {
+
+  public static void main(String... args) throws Exception {
+    
+    
+    Activity activity = new Activity();
+    
+    // Specify the audience
+    activity.addAudience(Audience.TO, new PersonObject("bob"));
+    activity.addAudience(Audience.CC, Extra.FRIENDS("Colleagues"));
+    activity.addAudience(Audience.BTO, new PersonObject("sally"));
+    activity.addAudience(Audience.BCC, Extra.NETWORK());
+    
+    // Indicate that this is a reply to something else
+    NoteObject note = new NoteObject();
+    note.setId("urn:foo:note:1");
+    activity.addInReplyTo(note);
+    
+    activity.writeTo(System.out);
+    
+    /**
+     * {"to":[
+     *   {"displayName":"bob",
+     *    "objectType":"person"}
+     *  ],
+     *  "inReplyTo":[
+     *    {"id":"urn:foo:note:1",
+     *     "objectType":"note"}
+     *  ],
+     *  "bto":[
+     *    {"displayName":"sally",
+     *     "objectType":"person"}
+     *  ],
+     *  "bcc":[
+     *    {"objectType":"@network"}
+     *  ],
+     *  "objectType":"activity",
+     *  "cc":[
+     *    {"id":"Colleagues",
+     *     "objectType":"@friends"}
+     *  ]
+     * }
+     */
+  }
+  
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/RepliesAndTargetingExample.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.appclient;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Link;
+import org.apache.abdera2.model.Service;
+import org.apache.abdera2.protocol.client.AbderaClient;
+import org.apache.abdera2.protocol.client.AbderaClientResponse;
+import org.apache.abdera2.protocol.client.AbderaSession;
+import org.apache.abdera2.protocol.client.Client;
+import org.apache.abdera2.common.iri.IRI;
+
+public class Main {
+
+    public static void main(String[] args) throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+        Client abderaClient = new AbderaClient(abdera);
+        AbderaSession session = abderaClient.newSession();
+        Factory factory = abdera.getFactory();
+
+        // Perform introspection. This is an optional step. If you already
+        // know the URI of the APP collection to POST to, you can skip it.
+        Document<Service> introspection = ((AbderaClientResponse)session.get(args[0])).getDocument();
+        Service service = introspection.getRoot();
+        Collection collection = service.getCollection(args[1], args[2]);
+        report("The Collection Element", collection.toString());
+
+        // Create the entry to post to the collection
+        Entry entry = factory.newEntry();
+        entry.setId("tag:example.org,2006:foo");
+        entry.setTitle("This is the title");
+        entry.setUpdated(new Date());
+        entry.addAuthor("James");
+        entry.setContent("This is the content");
+        report("The Entry to Post", entry.toString());
+
+        // Post the entry. Be sure to grab the resolved HREF of the collection
+        Document<Entry> doc = ((AbderaClientResponse)session.post(collection.getResolvedHref().toString(), entry)).getDocument();
+
+        // In some implementations (such as Google's GData API, the entry URI is
+        // distinct from it's edit URI. To be safe, we should assume it may be
+        // different
+        IRI entryUri = doc.getBaseUri();
+        report("The Created Entry", doc.getRoot().toString());
+
+        // Grab the Edit URI from the entry. The entry MAY have more than one
+        // edit link. We need to make sure we grab the right one.
+        IRI editUri = getEditUri(doc.getRoot());
+
+        // If there is an Edit Link, we can edit the entry
+        if (editUri != null) {
+            // Before we can edit, we need to grab an "editable" representation
+            doc = ((AbderaClientResponse)session.get(editUri.toString())).getDocument();
+
+            // Change whatever you want in the retrieved entry
+            doc.getRoot().getTitleElement().setValue("This is the changed title");
+
+            // Put it back to the server
+            session.put(editUri.toString(), doc.getRoot());
+
+            // This is just to show that the entry has been modified
+            doc = ((AbderaClientResponse)session.get(entryUri.toString())).getDocument();
+            report("The Modified Entry", doc.getRoot().toString());
+        } else {
+            // Otherwise, the entry cannot be modified (no suitable edit link was found)
+            report("The Entry cannot be modified", null);
+        }
+
+        // Delete the entry. Again, we need to make sure that we have the current
+        // edit link for the entry
+        doc = ((AbderaClientResponse)session.get(entryUri.toString())).getDocument();
+        editUri = getEditUri(doc.getRoot());
+        if (editUri != null) {
+            session.delete(editUri.toString());
+            report("The Enry has been deleted", null);
+        } else {
+            report("The Entry cannot be deleted", null);
+        }
+        abderaClient.shutdown();
+    }
+
+    private static IRI getEditUri(Entry entry) throws Exception {
+        IRI editUri = null;
+        List<Link> editLinks = entry.getLinks("edit");
+        for (Link link : editLinks) {
+            // if there is more than one edit link, we should not automatically
+            // assume that it's always going to point to an Atom document
+            // representation.
+            if (link.getMimeType() != null) {
+                if (link.getMimeType().match("application/atom+xml")) {
+                    editUri = link.getResolvedHref();
+                    break;
+                }
+            } else { // assume that an edit link with no type attribute is the right one to use
+                editUri = link.getResolvedHref();
+                break;
+            }
+        }
+        return editUri;
+    }
+
+    private static void report(String title, String message) {
+        System.out.println("== " + title + " ==");
+        if (message != null)
+            System.out.println(message);
+        System.out.println();
+    }
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/Main.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/README
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/README?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/README (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appclient/README Tue Sep 20 15:56:46 2011
@@ -0,0 +1,6 @@
+A simple APP Client implementation.
+
+To run:
+
+java org.apache.abdera.examples.appclient.Main {Introspection URI} {Workspace Name} {Collection Name}
+

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/AppServer.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/AppServer.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/AppServer.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/AppServer.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.appserver.employee;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.protocol.Provider;
+import org.apache.abdera2.common.protocol.servlet.AbderaServlet;
+import org.apache.abdera2.protocol.server.impl.DefaultAtompubProvider;
+import org.apache.abdera2.protocol.server.impl.SimpleWorkspaceInfo;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+
+public class AppServer {
+
+    public static void main(String... args) throws Exception {
+        int port = 9002;
+        try {
+            port = args.length > 0 ? Integer.parseInt(args[0]) : 9002;
+        } catch (Exception e) {
+        }
+        Server server = new Server(port);
+        ServletContextHandler handler = 
+          new ServletContextHandler(ServletContextHandler.SESSIONS);
+        handler.setContextPath("/");
+        server.setHandler(handler);
+        ServletHolder servletHolder = new ServletHolder(new EmployeeProviderServlet());
+        handler.addServlet(servletHolder, "/*");
+        server.start();
+        server.join();
+    }
+
+    // START SNIPPET: servlet
+    public static final class EmployeeProviderServlet extends AbderaServlet {
+        private static final long serialVersionUID = -549428240693531463L;
+
+        protected Provider createProvider() {
+            EmployeeCollectionAdapter ca = new EmployeeCollectionAdapter();
+            ca.setHref("employee");
+
+            SimpleWorkspaceInfo wi = new SimpleWorkspaceInfo();
+            wi.setTitle("Employee Directory Workspace");
+            wi.addCollection(ca);
+
+            DefaultAtompubProvider provider = new DefaultAtompubProvider("/");
+            provider.addWorkspace(wi);
+
+            provider.init(Abdera.getInstance(), null);
+            return provider;
+        }
+    }
+    // END SNIPPET: servlet
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/AppServer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/Employee.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/Employee.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/Employee.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/Employee.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.appserver.employee;
+
+import java.util.Date;
+
+// START SNIPPET: employee
+public class Employee {
+    private int id;
+    private String name;
+    private Date updated;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Date getUpdated() {
+        return updated;
+    }
+
+    public void setUpdated(Date updated) {
+        this.updated = updated;
+    }
+}
+// END SNIPPET: employee

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/Employee.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/EmployeeCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/EmployeeCollectionAdapter.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/EmployeeCollectionAdapter.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/EmployeeCollectionAdapter.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.appserver.employee;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.model.Content;
+import org.apache.abdera2.model.Person;
+import org.apache.abdera2.common.protocol.RequestContext;
+import org.apache.abdera2.common.protocol.ResponseContextException;
+import org.apache.abdera2.protocol.server.impl.AbstractEntityCollectionAdapter;
+
+public class EmployeeCollectionAdapter extends AbstractEntityCollectionAdapter<Employee> {
+    private static final String ID_PREFIX = "tag:acme.com,2007:employee:entry:";
+
+    private AtomicInteger nextId = new AtomicInteger(1000);
+    private Map<Integer, Employee> employees = new HashMap<Integer, Employee>();
+    private Factory factory = Abdera.getInstance().getFactory();
+
+    // START SNIPPET: feedmetadata
+    /**
+     * A unique ID for this feed.
+     */
+    public String getId(RequestContext request) {
+        return "tag:acme.com,2007:employee:feed";
+    }
+
+    /**
+     * The title of our collection.
+     */
+    public String getTitle(RequestContext request) {
+        return "Acme Employee Database";
+    }
+
+    /**
+     * The author of this collection.
+     */
+    public String getAuthor(RequestContext request) {
+        return "Acme Industries";
+    }
+
+    // END SNIPPET: feedmetadata
+    // START SNIPPET: getEntries
+    public Iterable<Employee> getEntries(RequestContext request) {
+        return employees.values();
+    }
+
+    // END SNIPPET: getEntries
+    // START SNIPPET: getEntry
+    public Employee getEntry(String resourceName, RequestContext request) throws ResponseContextException {
+        Integer id = getIdFromResourceName(resourceName);
+        return employees.get(id);
+    }
+
+    private Integer getIdFromResourceName(String resourceName) throws ResponseContextException {
+        int idx = resourceName.indexOf("-");
+        if (idx == -1) {
+            throw new ResponseContextException(404);
+        }
+        return new Integer(resourceName.substring(0, idx));
+    }
+
+    public String getName(Employee entry) {
+        return entry.getId() + "-" + entry.getName().replaceAll(" ", "_");
+    }
+
+    // END SNIPPET: getEntry
+    // START SNIPPET: entryMetadata
+    public String getId(Employee entry) {
+        return ID_PREFIX + entry.getId();
+    }
+
+    public String getTitle(Employee entry) {
+        return entry.getName();
+    }
+
+    public Date getUpdated(Employee entry) {
+        return entry.getUpdated();
+    }
+
+    public List<Person> getAuthors(Employee entry, RequestContext request) throws ResponseContextException {
+        Person author = factory.newAuthor();
+        author.setName("Acme Industries");
+        return Arrays.asList(author);
+    }
+
+    public Object getContent(Employee entry, RequestContext request) {
+        Content content = factory.newContent(Content.Type.TEXT);
+        content.setText(entry.getName());
+        return content;
+    }
+
+    // END SNIPPET: entryMetadata
+    // START SNIPPET: methods
+    public Employee postEntry(String title,
+                              IRI id,
+                              String summary,
+                              Date updated,
+                              List<Person> authors,
+                              Content content,
+                              RequestContext request) throws ResponseContextException {
+        Employee employee = new Employee();
+        employee.setName(content.getText().trim());
+        employee.setId(nextId.getAndIncrement());
+        employees.put(employee.getId(), employee);
+
+        return employee;
+    }
+
+    public void putEntry(Employee employee,
+                         String title,
+                         Date updated,
+                         List<Person> authors,
+                         String summary,
+                         Content content,
+                         RequestContext request) throws ResponseContextException {
+        employee.setName(content.getText().trim());
+    }
+
+    public void deleteEntry(String resourceName, RequestContext request) throws ResponseContextException {
+        Integer id = getIdFromResourceName(resourceName);
+        employees.remove(id);
+    }
+    // END SNIPPET: methods
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/EmployeeCollectionAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Bidi.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Bidi.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Bidi.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Bidi.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.ext;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.bidi.BidiHelper;
+import org.apache.abdera2.ext.bidi.BidiHelper.Direction;
+import org.apache.abdera2.model.Entry;
+
+/**
+ * The Atom Bidi Extension is described in an IETF Internet-Draft and is used to communicate information about the base
+ * directionality of text in an Atom document.
+ */
+public class Bidi {
+
+    public static void main(String... args) throws Exception {
+
+        String text = "\u05e4\u05e2\u05d9\u05dc\u05d5\u05ea \u05d4\u05d1\u05d9\u05e0\u05d0\u05d5\u05dd, W3C";
+
+        Abdera abdera =Abdera.getInstance();
+        Entry entry = abdera.newEntry();
+        BidiHelper.setDirection(Direction.RTL, entry);
+
+        entry.setTitle(text);
+
+        // non bidi, incorrectly displayed
+        System.out.println(entry.getTitle());
+
+        // with bidi, correctly displayed
+        System.out.println(BidiHelper.getBidiElementText(entry.getTitleElement()));
+
+        // with bidi, correctly displayed
+        System.out.println(BidiHelper.getBidiText(BidiHelper.getDirection(entry), entry.getTitle()));
+
+        // there are also direction guessing algorithms available
+        entry = abdera.newEntry();
+        entry.setTitle(text);
+        entry.setLanguage("ar");
+
+        System.out.println(BidiHelper.guessDirectionFromJavaBidi(entry.getTitleElement()));
+        System.out.println(BidiHelper.guessDirectionFromTextProperties(entry.getTitleElement()));
+        System.out.println(BidiHelper.guessDirectionFromLanguage(entry.getTitleElement()));
+    }
+
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Bidi.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Features.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Features.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Features.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Features.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.ext;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.features.Feature;
+import org.apache.abdera2.ext.features.FeatureSelector;
+import org.apache.abdera2.ext.features.FeaturesHelper;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.model.Service;
+import org.apache.abdera2.model.Workspace;
+
+/**
+ * The Atompub Features Extension is described in an IETF I-D and is used to communicate information about features that
+ * are supported, required or unsupported by an Atompub collection.
+ */
+public class Features {
+
+    public static void main(String... args) throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+        Service service = abdera.newService();
+        Workspace workspace = service.addWorkspace("My workspace");
+        Collection collection = workspace.addCollection("My collection", "foo");
+
+        // Specify which features are supported by the collection
+        org.apache.abdera2.ext.features.Features features = FeaturesHelper.addFeaturesElement(collection);
+        features.addFeature(FeaturesHelper.FEATURE_SUPPORTS_DRAFTS);
+        features.addFeature(FeaturesHelper.FEATURE_REQUIRES_TEXT_TEXT);
+        features.addFeature(FeaturesHelper.FEATURE_IGNORES_SLUG);
+        features.addFeature(FeaturesHelper.FEATURE_SUPPORTS_BIDI);
+
+        // Get the support status of a specific feature
+        System.out.println(FeaturesHelper.getFeatureStatus(collection, FeaturesHelper.FEATURE_SUPPORTS_DRAFTS));
+        System.out.println(FeaturesHelper.getFeatureStatus(collection, FeaturesHelper.FEATURE_REQUIRES_TEXT_TEXT));
+        System.out.println(FeaturesHelper.getFeatureStatus(collection, FeaturesHelper.FEATURE_IGNORES_SLUG));
+        System.out.println(FeaturesHelper.getFeatureStatus(collection, FeaturesHelper.FEATURE_SUPPORTS_BIDI));
+        System.out.println(FeaturesHelper.getFeatureStatus(collection, FeaturesHelper.FEATURE_SUPPORTS_GEO));
+
+        Iterable<Feature> fs = FeaturesHelper.getFeatures(collection);
+        for (Feature feature : fs) {
+            System.out.println("\t" + feature.getRef());
+        }
+
+        // Select a collection by feature
+        Iterable<Collection> selectedCollections =
+            FeaturesHelper.select(service, new FeatureSelector(FeaturesHelper.FEATURE_SUPPORTS_DRAFTS,
+                                                               FeaturesHelper.FEATURE_SUPPORTS_BIDI));
+        System.out.println("Selected Collections:");
+        for (Collection selected : selectedCollections)
+            System.out.println("\t" + selected.getTitle());
+
+    }
+
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Features.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Geo.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Geo.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Geo.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Geo.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.ext;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.geo.Coordinate;
+import org.apache.abdera2.ext.geo.GeoHelper;
+import org.apache.abdera2.common.geo.Point;
+import org.apache.abdera2.common.geo.Position;
+import org.apache.abdera2.model.Entry;
+
+/**
+ * The Geo extensions allow Atom entries to be geotagged using the Georss extensions.
+ */
+public class Geo {
+
+    public static void main(String... args) throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+        Entry entry = abdera.newEntry();
+        entry.setTitle("Middle of the Ocean");
+
+        Point point = new Point(new Coordinate(37.0625, -95.677068));
+        
+        // Output position as ISO 6709 standard format
+        System.out.println(point.getCoordinate().asIsoPosition());
+        
+        GeoHelper.Encoding.SIMPLE.addPosition(entry,point);
+
+        Iterable<Position> positions = GeoHelper.getPositions(entry);
+        for (Position pos : positions) {
+            if (pos instanceof Point) {
+                Point p = (Point)pos;
+                System.out.println(p.getCoordinate());
+            }
+        }
+
+        // By default, positions are encoded using the simple georss encoding,
+        // W3C and GML encodings are also supported
+        
+        GeoHelper.Encoding.W3C.addPosition(entry, point);
+        GeoHelper.Encoding.GML.addPosition(entry, point);
+        
+        entry.writeTo("prettyxml",System.out);
+    }
+
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Geo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Json.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Json.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Json.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Json.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.ext;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.model.Entry;
+
+/**
+ * The JSONWriter can be used to serialize an Abdera entry into a JSON structure
+ */
+public class Json {
+
+    public static void main(String... args) throws Exception {
+
+        Abdera abdera =Abdera.getInstance();
+        Entry entry = abdera.newEntry();
+        entry.newId();
+        entry.setTitle("test");
+        entry.setContentAsHtml("<b>foo</b>");
+        entry.addAuthor("James");
+        entry.addCategory("term");
+        entry.writeTo("json", System.out);
+
+        /**
+         * Produces: { "id":"urn:uuid:97893C35372BE77BD51200273434152", "title":"test", "content":{
+         * "attributes":{"type":"html"}, "children":[{ "name":"b", "attributes":{}, "children":["foo"]}]},
+         * "authors":[{"name":"James"}], "categories":[{"term":"term"}] }
+         */
+    }
+
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Json.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/License.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/License.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/License.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/License.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.ext;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.license.LicenseHelper;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+import org.apache.abdera2.model.Link;
+
+/**
+ * The Atom License extension is described in Experimental RFC4946 and provides a way of associating copyright licenses
+ * with feeds and entries. This is useful when working with things like Creative Commons licenses.
+ */
+public class License {
+
+    public static void main(String... args) throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+        Feed feed = abdera.newFeed();
+        Entry entry = feed.addEntry();
+
+        // Add a license to the feed
+        LicenseHelper.addLicense(feed, "http://example.org/foo", "Foo");
+
+        // does the feed have a license link?
+        System.out.println(LicenseHelper.hasLicense(feed));
+
+        // does the feed have a specific license link?
+        System.out.println(LicenseHelper.hasLicense(feed, "http://example.org/foo"));
+
+        // since the entry does not have a license, it inherits the feeds
+        System.out.println(LicenseHelper.hasLicense(entry));
+        System.out.println(LicenseHelper.hasLicense(entry, "http://example.org/foo"));
+
+        // list the licenses
+        Iterable<Link> licenses = LicenseHelper.getLicense(entry);
+        for (Link link : licenses) {
+            System.out.println(link.getResolvedHref());
+        }
+
+        // Add an unspecified license to the entry
+        LicenseHelper.addUnspecifiedLicense(entry);
+
+        // now the entry does not inherit the feeds license
+        System.out.println(LicenseHelper.hasLicense(entry, "http://example.org/foo"));
+
+    }
+
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/License.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Paging.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Paging.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Paging.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Paging.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.ext;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.templates.MapContext;
+import org.apache.abdera2.common.templates.Template;
+import org.apache.abdera2.ext.history.FeedPagingHelper;
+import org.apache.abdera2.model.Feed;
+
+public class Paging {
+
+    private static final Template template = new Template("feed{?page}");
+  
+    private static String gen(int page) {
+      MapContext mc = new MapContext();
+      if (page > -1)
+        mc.put("page", page);
+      return template.expand(mc);
+    }
+    
+    public static void main(String... args) throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+        Feed feed = abdera.newFeed();
+        
+
+        // Set/Get the paging links
+        FeedPagingHelper.setCurrent(feed, gen(-1));
+        FeedPagingHelper.setNext(feed, gen(3));
+        FeedPagingHelper.setPrevious(feed, gen(1));
+        FeedPagingHelper.setFirst(feed, gen(-1));
+        FeedPagingHelper.setLast(feed, gen(10));
+        FeedPagingHelper.setNextArchive(feed, gen(3));
+        FeedPagingHelper.setPreviousArchive(feed, gen(1));
+
+        System.out.println(FeedPagingHelper.getCurrent(feed));
+        System.out.println(FeedPagingHelper.getNext(feed));
+        System.out.println(FeedPagingHelper.getPrevious(feed));
+        System.out.println(FeedPagingHelper.getFirst(feed));
+        System.out.println(FeedPagingHelper.getLast(feed));
+        System.out.println(FeedPagingHelper.getNextArchive(feed));
+        System.out.println(FeedPagingHelper.getPreviousArchive(feed));
+
+        // Set/Get the archive flag
+        FeedPagingHelper.setArchive(feed, true);
+        if (FeedPagingHelper.isArchive(feed))
+            System.out.println("archive feed!");
+
+        // Set/Get the complete flag
+        FeedPagingHelper.setComplete(feed, true);
+        if (FeedPagingHelper.isComplete(feed))
+            System.out.println("complete feed!");
+
+    }
+
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Paging.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Serializer.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Serializer.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Serializer.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Serializer.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.ext;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.serializer.ConventionSerializationContext;
+import org.apache.abdera2.ext.serializer.annotation.Author;
+import org.apache.abdera2.ext.serializer.annotation.ID;
+import org.apache.abdera2.ext.serializer.annotation.Link;
+import org.apache.abdera2.ext.serializer.annotation.Published;
+import org.apache.abdera2.ext.serializer.annotation.Summary;
+import org.apache.abdera2.ext.serializer.annotation.Title;
+import org.apache.abdera2.ext.serializer.annotation.Updated;
+import org.apache.abdera2.ext.serializer.impl.EntrySerializer;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.writer.StreamWriter;
+
+/**
+ * The Serializer extension allows Java objects to be automatically serialized into Atom documents using the objects
+ * public getters or fields. The implementation is still largely experimental
+ */
+public class Serializer {
+
+    static Date date_now = new Date();
+    static Calendar cal_now = Calendar.getInstance();
+
+    public static void main(String... args) throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+
+        // demonstrate serialization of a non-annotated java object
+        StreamWriter sw = abdera.create(StreamWriter.class);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        sw.setOutputStream(out).setAutoIndent(true);
+        ConventionSerializationContext c = new ConventionSerializationContext(sw);
+        c.setSerializer(MyEntry.class, new EntrySerializer());
+        sw.startDocument();
+        c.serialize(new MyEntry());
+        sw.endDocument();
+
+        // once the object has been serialized, we can see that it's a parseable Atom document
+        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+        Document<Entry> doc = abdera.getParser().parse(in);
+        Entry entry = doc.getRoot();
+        entry.writeTo(System.out);
+
+        System.out.println();
+
+        // demonstrate serialization using an annotated java object
+        // annotations allow the developer to customize the way the
+        // object is serialized
+        sw = abdera.create(StreamWriter.class);
+        out = new ByteArrayOutputStream();
+        sw.setOutputStream(out).setAutoIndent(true);
+        c = new ConventionSerializationContext(sw);
+        // no need to set the serializer for the class!
+        sw.startDocument();
+        c.serialize(new MyAnnotatedEntry());
+        sw.endDocument();
+
+        in = new ByteArrayInputStream(out.toByteArray());
+        doc = abdera.getParser().parse(in);
+        entry = doc.getRoot();
+        entry.writeTo(System.out);
+    }
+
+    public static class MyEntry {
+        public String getId() {
+            return "tag:example.org,2008:foo";
+        }
+
+        public String getTitle() {
+            return "This is the title";
+        }
+
+        public String getAuthor() {
+            return "James";
+        }
+
+        public Date getUpdated() {
+            return date_now;
+        }
+
+        public Calendar getPublished() {
+            return cal_now;
+        }
+
+        public String getSummary() {
+            return "this is the summary";
+        }
+
+        public String getLink() {
+            return "http://example.org/foo";
+        }
+    }
+
+    @org.apache.abdera2.ext.serializer.annotation.Entry
+    public static class MyAnnotatedEntry {
+        @ID
+        public String getFoo() {
+            return "tag:example.org,2008:foo";
+        }
+
+        @Title
+        public String getBar() {
+            return "This is the title";
+        }
+
+        @Author
+        public String getBaz() {
+            return "James";
+        }
+
+        @Updated
+        @Published
+        public Date getLastModified() {
+            return date_now;
+        }
+
+        @Summary
+        public String getText() {
+            return "this is the summary";
+        }
+
+        @Link
+        public String getUri() {
+            return "http://example.org/foo";
+        }
+    }
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Serializer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Sharing.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Sharing.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Sharing.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Sharing.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.examples.ext;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.sharing.Conflicts;
+import org.apache.abdera2.ext.sharing.SharingHelper;
+import org.apache.abdera2.ext.sharing.Sync;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+
+/**
+ * Basic Simple Sharing Extensions support
+ */
+public class Sharing {
+
+    public static void main(String... args) throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+
+        // Create two feeds
+        Feed f1 = abdera.newFeed();
+        Feed f2 = abdera.newFeed();
+
+        // Create a couple of sharing-enabled entries
+        Entry e1 = SharingHelper.createEntry(abdera, "jms", f1);
+        e1.newId();
+
+        Entry e2 = SharingHelper.createEntry(abdera, "jms", f1);
+        e2.newId();
+
+        Entry e3 = (Entry)e2.clone();
+        f2.addEntry(e3);
+
+        // concurrent modification of the same entry by two different users in two different feeds
+        SharingHelper.updateEntry(e2, "bob");
+        SharingHelper.updateEntry(e3, "joe");
+
+        // prepare a third feed for merging
+        Feed f3 = (Feed)f2.clone();
+
+        // merge f1 with f2 to produce f3
+        SharingHelper.mergeFeeds(f1, f3);
+
+        // there will be two entries in f3, one of which shows a conflict
+        for (Entry entry : f3.getEntries()) {
+            System.out.println(entry.getId());
+            if (SharingHelper.hasConflicts(entry)) {
+                Sync sync = SharingHelper.getSync(entry);
+                Conflicts conflicts = sync.getConflicts();
+                System.out.println("\tNumber of conflicts: " + conflicts.getEntries().size());
+            }
+        }
+
+    }
+
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/ext/Sharing.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message