You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2011/11/03 18:31:26 UTC
svn commit: r1197233 - in /abdera/abdera2: activities/
activities/src/main/java/org/apache/abdera2/activities/model/ client/
common/ common/src/main/java/org/apache/abdera2/common/anno/ core/
examples/src/main/java/org/apache/abdera2/examples/activitie...
Author: jmsnell
Date: Thu Nov 3 17:31:25 2011
New Revision: 1197233
URL: http://svn.apache.org/viewvc?rev=1197233&view=rev
Log:
documentation updates... osgi manifest stuff...
Modified:
abdera/abdera2/activities/pom.xml
abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Generator.java
abdera/abdera2/client/pom.xml
abdera/abdera2/common/pom.xml
abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/DefaultImplementation.java
abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Namespace.java
abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Param.java
abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/QName.java
abdera/abdera2/core/pom.xml
abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java
abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java
abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java
abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtensionExample.java
abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java
abdera/abdera2/ext/pom.xml
abdera/abdera2/security/pom.xml
abdera/abdera2/server/pom.xml
abdera/abdera2/test/pom.xml
Modified: abdera/abdera2/activities/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/pom.xml?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/activities/pom.xml (original)
+++ abdera/abdera2/activities/pom.xml Thu Nov 3 17:31:25 2011
@@ -33,16 +33,14 @@
<description>JSON Activity Streams Implementation</description>
<properties>
- <topDir>${basedir}/..</topDir>
- <!--
+ <topDir>${basedir}/..</topDir>
<abdera.osgi.default.exports>
- org.apache.abdera.activities.*
+ org.apache.abdera2.activities.*
</abdera.osgi.default.exports>
<abdera.osgi.default.imports>
org.apache.commons.codec*;version="[1.5,2)",
*
</abdera.osgi.default.imports>
- -->
</properties>
<dependencies>
Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Generator.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Generator.java?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Generator.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Generator.java Thu Nov 3 17:31:25 2011
@@ -26,6 +26,7 @@ public class Generator<T extends ASBase>
this.template = template;
}
+ @SuppressWarnings("unchecked")
public <X extends Generator<T>>X startNew() {
if (item != null)
throw new IllegalStateException();
@@ -47,6 +48,7 @@ public class Generator<T extends ASBase>
return (X)this;
}
+ @SuppressWarnings("unchecked")
public <X extends Generator<T>>X set(String name, Object value) {
if (item == null)
throw new IllegalStateException();
Modified: abdera/abdera2/client/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/client/pom.xml?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/client/pom.xml (original)
+++ abdera/abdera2/client/pom.xml Thu Nov 3 17:31:25 2011
@@ -33,7 +33,6 @@
<properties>
<topDir>${basedir}/..</topDir>
- <!--
<abdera.osgi.default.exports>
org.apache.abdera2.protocol.client.*
</abdera.osgi.default.exports>
@@ -41,7 +40,6 @@
org.apache.commons.codec*;version="[1.5,2)",
*
</abdera.osgi.default.imports>
- -->
</properties>
<dependencies>
Modified: abdera/abdera2/common/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/pom.xml?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/common/pom.xml (original)
+++ abdera/abdera2/common/pom.xml Thu Nov 3 17:31:25 2011
@@ -37,7 +37,6 @@
<properties>
<topDir>${basedir}/..</topDir>
- <!--
<abdera.osgi.default.exports>
org.apache.abdera2.common.*
</abdera.osgi.default.exports>
@@ -45,7 +44,6 @@
org.apache.commons.codec*;version="[1.5,2)",
*
</abdera.osgi.default.imports>
- -->
</properties>
@@ -81,6 +79,11 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ </dependency>
</dependencies>
</project>
Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/DefaultImplementation.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/DefaultImplementation.java?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/DefaultImplementation.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/DefaultImplementation.java Thu Nov 3 17:31:25 2011
@@ -23,6 +23,10 @@ import static java.lang.annotation.Reten
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ * Used on Interface classes to identify the default implementation
+ * class when using the Abdera Discover mechanism
+ */
@Retention(RUNTIME)
@Target( {TYPE})
public @interface DefaultImplementation {
Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Namespace.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Namespace.java?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Namespace.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Namespace.java Thu Nov 3 17:31:25 2011
@@ -22,6 +22,10 @@ import static java.lang.annotation.Reten
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ * Used by Extension Factory classes to specify the XML namespaces
+ * handled by the factory
+ */
@Retention(RUNTIME)
@Target( {TYPE})
public @interface Namespace {
Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Param.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Param.java?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Param.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Param.java Thu Nov 3 17:31:25 2011
@@ -6,6 +6,10 @@ import static java.lang.annotation.Reten
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ * Used with the Context Annotation to establish a static context
+ * primarily for use with the URI Template implementation
+ */
@Retention(RUNTIME)
@Target( {TYPE})
public @interface Param {
Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/QName.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/QName.java?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/QName.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/QName.java Thu Nov 3 17:31:25 2011
@@ -24,6 +24,9 @@ import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+/**
+ * Used primarily to associate an XML Qualified name with an interface
+ */
@Retention(RUNTIME)
@Target( {TYPE})
@Inherited
Modified: abdera/abdera2/core/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/pom.xml?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/core/pom.xml (original)
+++ abdera/abdera2/core/pom.xml Thu Nov 3 17:31:25 2011
@@ -33,8 +33,7 @@
<description>Atom Specification Implementation Core</description>
<properties>
- <topDir>${basedir}/..</topDir>
- <!--
+ <topDir>${basedir}/..</topDir>
<abdera.osgi.default.exports>
org.apache.abdera2;
org.apache.abdera2.extra.*;
@@ -54,7 +53,6 @@
org.apache.commons.codec*;version="[1.5,2)",
*
</abdera.osgi.default.imports>
- -->
</properties>
<dependencies>
Modified: 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=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/Activities.java Thu Nov 3 17:31:25 2011
@@ -15,7 +15,17 @@ public class Activities {
public static void main(String... args) throws Exception {
// Simple Activities Example
+ IO io = IO.get();
+
+ // A simple fluent factory model can be used to create
+ // activities and their associated objects... several
+ // of the methods here are statically imported so be
+ // sure to take a look at the import statements at
+ // the top of the class to see where various bits are
+ // coming from.
+ //
+ // this activity basically says: "James is following John"
Activity activity =
makeActivity()
.actor(
@@ -30,11 +40,19 @@ public class Activities {
.get())
.get();
- activity.writeTo(System.out);
+ // All activities objects can handle their own serialization
+ // using the writeTo method, or you can use the IO object
+ // directly... reusing the IO object will be more efficient
+ // if you're doing a lot of serialization of objects
+ activity.writeTo(io,System.out);
System.out.println("\n\n\n");
- // Activity Stream
+ // Now that we have a single activity, let's create the
+ // "Activity Stream"... a stream is essentially a
+ // Collection Object whose items are all Activities.
+ // It's possible to have Collections of other types
+ // of objects too..
Collection<Activity> collection =
Collection.<Activity>makeCollection()
.item(activity)
@@ -50,7 +68,7 @@ public class Activities {
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
- collection = IO.get().readCollection(in, "UTF-8");
+ collection = io.readCollection(in, "UTF-8");
for (Activity a : collection.getItems()) {
System.out.println(
Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/BinaryDataObjectExample.java Thu Nov 3 17:31:25 2011
@@ -26,16 +26,19 @@ public class BinaryDataObjectExample {
IO io = IO.get();
+ // First prepare the data we wish to include
+ // within the object...
URL url = BinaryDataObjectExample.class.getResource("/info.png");
DataHandler dataHandler = new DataHandler(url);
+ // Let's create a badge object and attach the data object...
BadgeObject badge =
makeBadge()
.attachment(
makeBinary()
.data(
dataHandler,
- new Md5(), // generate an md5 hash and set an "md5" property
+ new Md5(), // generate an md5 hash and set an "md5" property.. we could also do an hmac here
DEFLATE) // apply deflate compression to the data before encoding it
.get())
.get();
@@ -45,20 +48,22 @@ public class BinaryDataObjectExample {
badge = io.readObject(sr);
+ // grab the binary object from the attachments...
BinaryObject dataObject = (BinaryObject) badge.getAttachments().iterator().next();
String md5 = dataObject.getProperty("md5");
Md5 check = new Md5();
- // decompression will be applied automatically
+ // decompression and base64 decoding will be applied automatically
+ // when we read the inputstream provided by getInputStream()...
InputStream in = dataObject.getInputStream();
- byte[] buf = new byte[100];
+ byte[] buf = new byte[1024];
int r = -1;
while((r = in.read(buf)) > -1)
check.update(buf, 0, r);
+ // check the md5 hash to show that the input data and output data are the same
String checks = check.get();
-
System.out.println(checks.equalsIgnoreCase(md5));
}
Modified: 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=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtendingBaseObjectExample.java Thu Nov 3 17:31:25 2011
@@ -18,6 +18,9 @@ public class ExtendingBaseObjectExample
IO io = IO.get();
EventObject event = new EventObject();
event.setObjectType("hangout");
+ // the extend method dynamically attaches a new interface
+ // to the object that can be used to specify extension
+ // properties in a typesafe manner
AdditionalEventProperties ext =
event.extend(
AdditionalEventProperties.class);
Modified: 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=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtensionExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ExtensionExample.java Thu Nov 3 17:31:25 2011
@@ -17,14 +17,20 @@ public class ExtensionExample {
// create the io with our custom type adapter
IO io = IO.get(new BarAdapter());
+
+ // tell the serializer how to handle specific property names
io.addPropertyMapping("bar", Bar.class);
io.addPropertyMapping("etag", EntityTag.class);
+ // create a new object with "objectType":"foo"
ASObject as = new ASObject("foo");
+
+ // attach the Foo.class interface to the object to set
+ // extension properties
Foo foo = as.extend(Foo.class);
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");
@@ -48,7 +54,7 @@ public class ExtensionExample {
System.out.println(foo.getBar().getClass());
- // map will deserialize as an asobject
+ // map will deserialize as an asobject...
System.out.println(as.getProperty("map").getClass());
}
Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java Thu Nov 3 17:31:25 2011
@@ -12,6 +12,11 @@ public class FeedToStreamConversionExamp
public static void main(String... args) throws Exception {
+ // this example converts an Atom Feed to a
+ // JSON Activity Stream. the call to
+ // feed.writeTo("activity", ...) engages
+ // the named writer instance that handles
+ // the transformation.
Abdera abdera = Abdera.getInstance();
URL url = new URL("http://intertwingly.net/blog/index.atom");
Parser parser = abdera.getParser();
Modified: abdera/abdera2/ext/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/pom.xml?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/ext/pom.xml (original)
+++ abdera/abdera2/ext/pom.xml Thu Nov 3 17:31:25 2011
@@ -34,7 +34,6 @@
<properties>
<topDir>${basedir}/..</topDir>
- <!--
<abdera.osgi.default.exports>
org.apache.abdera2.protocol.ext.*
</abdera.osgi.default.exports>
@@ -42,7 +41,6 @@
org.apache.commons.codec*;version="[1.3,2)",
*
</abdera.osgi.default.imports>
- -->
</properties>
<dependencies>
Modified: abdera/abdera2/security/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/security/pom.xml?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/security/pom.xml (original)
+++ abdera/abdera2/security/pom.xml Thu Nov 3 17:31:25 2011
@@ -33,16 +33,14 @@
<description>Atom Publishing Protocol Security Implementation</description>
<properties>
- <topDir>${basedir}/..</topDir>
- <!--
+ <topDir>${basedir}/..</topDir>
<abdera.osgi.default.exports>
- org.apache.abdera.protocol.client.*
+ org.apache.abdera2.security.*
</abdera.osgi.default.exports>
<abdera.osgi.default.imports>
org.apache.commons.codec*;version="[1.5,2)",
*
</abdera.osgi.default.imports>
- -->
</properties>
<dependencies>
Modified: abdera/abdera2/server/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/pom.xml?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/server/pom.xml (original)
+++ abdera/abdera2/server/pom.xml Thu Nov 3 17:31:25 2011
@@ -33,16 +33,14 @@
<description>Atom Publishing Protocol Server Implementation</description>
<properties>
- <topDir>${basedir}/..</topDir>
- <!--
+ <topDir>${basedir}/..</topDir>
<abdera.osgi.default.exports>
- org.apache.abdera.protocol.client.*
+ org.apache.abdera2.protocol.server.*
</abdera.osgi.default.exports>
<abdera.osgi.default.imports>
org.apache.commons.codec*;version="[1.3,2)",
*
</abdera.osgi.default.imports>
- -->
</properties>
<dependencies>
Modified: abdera/abdera2/test/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/pom.xml?rev=1197233&r1=1197232&r2=1197233&view=diff
==============================================================================
--- abdera/abdera2/test/pom.xml (original)
+++ abdera/abdera2/test/pom.xml Thu Nov 3 17:31:25 2011
@@ -27,24 +27,11 @@
</parent>
<artifactId>abdera2-test</artifactId>
- <packaging>bundle</packaging>
+ <packaging>jar</packaging>
<name>Abdera2 Tests</name>
<version>2.0-SNAPSHOT</version>
<description>Abdera Tests</description>
- <properties>
- <topDir>${basedir}/..</topDir>
- <!--
- <abdera.osgi.default.exports>
- org.apache.abdera.protocol.client.*
- </abdera.osgi.default.exports>
- <abdera.osgi.default.imports>
- org.apache.commons.codec*;version="[1.5,2)",
- *
- </abdera.osgi.default.imports>
- -->
- </properties>
-
<build>
<testSourceDirectory>src/main/java</testSourceDirectory>
</build>