abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1195583 [1/2] - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/model/ activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ common/src/main/java/org/apache/abdera2/common/ common/src/main/java...
Date Mon, 31 Oct 2011 17:42:22 GMT
Author: jmsnell
Date: Mon Oct 31 17:42:21 2011
New Revision: 1195583

URL: http://svn.apache.org/viewvc?rev=1195583&view=rev
Log: (empty)

Added:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/SimpleListener.java   (with props)
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/PusherExample.java   (with props)
Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Generator.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/CollectionAdapterManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Discover.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Localizer.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/AnnoUtil.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Context.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Name.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Version.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControlUtil.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Chain.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/model/ElementList.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java
    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/GeneratorStreamingExample.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java
    abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/serializer/ObjectResponseContext.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubResponseContext.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubServiceManager.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/EntityProviderResponseContext.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/FOMResponseContext.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/ResponseContextWrapper.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterManager.java

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=1195583&r1=1195582&r2=1195583&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 Mon Oct 31 17:42:21 2011
@@ -26,7 +26,7 @@ public class Generator<T extends ASBase>
     this.template = template;
   }
   
-  public Generator<T> startNew() {
+  public <X extends Generator<T>>X startNew() {
     if (item != null) 
       throw new IllegalStateException();
     try {
@@ -44,14 +44,14 @@ public class Generator<T extends ASBase>
     } catch (Throwable t) {
       throw new RuntimeException(t);
     }
-    return this;
+    return (X)this;
   }
   
-  public Generator<T> set(String name, Object value) {
+  public <X extends Generator<T>>X set(String name, Object value) {
     if (item == null)
       throw new IllegalStateException();
     item.setProperty(name,value);
-    return this;
+    return (X)this;
   }
   
   public T complete() {

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/CollectionAdapterManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/CollectionAdapterManager.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/CollectionAdapterManager.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/CollectionAdapterManager.java Mon Oct 31 17:42:21 2011
@@ -92,9 +92,8 @@ public class CollectionAdapterManager {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         Class<?> adapterClass = cl.loadClass(config.getAdapterClassName());
         Constructor<?>[] ctors = adapterClass.getConstructors();
-        for (Constructor<?> element : ctors) {
-            logger.finest("Public constructor found: " + element.toString());
-        }
+        for (Constructor<?> element : ctors)
+          logger.finest("Public constructor found: " + element.toString());
         Constructor<?> c = adapterClass.getConstructor(new Class[] {FeedConfiguration.class});
         c.setAccessible(true);
         CollectionAdapter adapterInstance = (CollectionAdapter)c.newInstance(config);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Discover.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Discover.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Discover.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Discover.java Mon Oct 31 17:42:21 2011
@@ -28,7 +28,11 @@ import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
+import javax.annotation.Nullable;
+
 import org.apache.abdera2.common.anno.AnnoUtil;
+import org.apache.abdera2.common.misc.ExceptionHelper;
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -40,15 +44,33 @@ public final class Discover {
     private final static Log log = LogFactory.getLog(Discover.class);
     private Discover() {}
 
-    public static <T> T locate(Class<T> _class, String defaultImpl, Object... args) {
-        return (T)locate(_class, defaultImpl, getLoader(), args);
+    public static <T> T locate(
+      Class<T> _class, 
+      @Nullable String defaultImpl, 
+      Object... args) {
+        return (T)locate(
+          _class, 
+          defaultImpl, 
+          getLoader(), 
+          args);
     }
     
-    public static <T> T locate(String id, String defaultImpl, Object... args) {
-        return (T)locate(id, defaultImpl, getLoader(), args);
-    }
-
-    public static <T> T locate(Class<T> _class, String defaultImpl, ClassLoader loader, Object... args) {
+    public static <T> T locate(
+      String id, 
+      @Nullable String defaultImpl, 
+      Object... args) {
+        return (T)locate(
+          id, 
+          defaultImpl, 
+          getLoader(), 
+          args);
+    }
+
+    public static <T> T locate(
+      Class<T> _class, 
+      @Nullable String defaultImpl, 
+      ClassLoader loader, 
+      Object... args) {
       try {
         T instance = null, first = null;
         Iterable<T> items = 
@@ -73,7 +95,11 @@ public final class Discover {
       }      
     }
     
-    public static <T> T locate(String id, String defaultImpl, ClassLoader loader, Object... args) {
+    public static <T> T locate(
+      String id, 
+      @Nullable String defaultImpl, 
+      ClassLoader loader, 
+      Object... args) {
         try {
             T instance = null;
             Iterable<T> items = 
@@ -94,247 +120,346 @@ public final class Discover {
         return Thread.currentThread().getContextClassLoader();
     }
 
-    public static <T> Iterable<T> locate(Class<T> _class, ClassLoader cl, Object... args) {
+    public static <T> Iterable<T> locate(
+      Class<T> _class, 
+      @Nullable ClassLoader cl, 
+      Object... args) {
         return locate(_class, false, cl, args);
     }
     
-    public static <T> Iterable<T> locate(String id, ClassLoader cl, Object... args) {
+    public static <T> Iterable<T> locate(
+      String id, 
+      @Nullable ClassLoader cl, 
+      Object... args) {
         return locate(id, false, cl, args);
     }
 
-    public static <T> Iterable<T> locate(Class<T> _class, boolean classesonly, ClassLoader cl, Object... args) {
-      return locate(_class, classesonly, new DefaultLoader<T>(_class, classesonly, args, cl));
+    public static <T> Iterable<T> locate(
+      Class<T> _class, 
+      boolean classesonly, 
+      @Nullable ClassLoader cl, 
+      Object... args) {
+      return locate(
+        _class, 
+        classesonly, 
+        new DefaultLoader<T>(
+          _class, 
+          classesonly, 
+          args, 
+          cl));
     }
     
-    public static <T> Iterable<T> locate(String id, boolean classesonly, ClassLoader cl, Object... args) {
-        return locate(id, classesonly, new DefaultLoader<T>(id, classesonly, args, cl));
-    }
-
-    public static <T> Iterable<T> locate(Class<T> _class, Object...args) {
-      return locate(_class, false, args);
+    public static <T> Iterable<T> locate(
+      String id, 
+      boolean classesonly, 
+      @Nullable ClassLoader cl, 
+      Object... args) {
+        return locate(
+          id, 
+          classesonly, 
+          new DefaultLoader<T>(
+            id, 
+            classesonly, 
+            args, 
+            cl));
+    }
+
+    public static <T> Iterable<T> locate(
+      Class<T> _class, 
+      Object...args) {
+      return locate(
+        _class, 
+        false, 
+        args);
     }
     
-    public static <T> Iterable<T> locate(String id, Object... args) {
+    public static <T> Iterable<T> locate(
+      String id, 
+      Object... args) {
         return locate(id, false, args);
     }
 
-    public static <T> Iterable<T> locate(Class<T> _class, boolean classesonly, Object... args) {
-      return locate(new DefaultLoader<T>(_class, classesonly, args));
+    public static <T> Iterable<T> locate(
+      Class<T> _class, 
+      boolean classesonly, 
+      Object... args) {
+        return locate(
+          new DefaultLoader<T>(
+            _class, 
+            classesonly, 
+            args));
     }
     
-    public static <T> Iterable<T> locate(String id, boolean classesonly, Object... args) {
-        return locate(new DefaultLoader<T>(id, classesonly, args));
+    public static <T> Iterable<T> locate(
+      String id, 
+      boolean classesonly, 
+      Object... args) {
+        return locate(
+          new DefaultLoader<T>(
+            id, 
+            classesonly, 
+            args));
     }
 
-    public static <T> Iterable<T> locate(Iterable<T> loader) {
+    public static <T> Iterable<T> locate(
+      Iterable<T> loader) {
         Set<T> impls = new LinkedHashSet<T>();
         try {
-            for (T instance : loader) {
-              if (instance != null)
-                impls.add(instance);
-            }
+          for (T instance : loader)
+            if (instance != null)
+              impls.add(instance);
         } catch (Throwable t) {
-            log.error(t);
+          log.error(t);
         }
         return impls;
     }
 
-    public static class DefaultLoader<T> implements Iterable<T> {
+    public static class DefaultLoader<T> 
+      implements Iterable<T> {
         protected final ClassLoader loader;
         protected final String id;
         protected final Iterator<T> iterator;
         protected final Object[] args;
 
-        public DefaultLoader(String id, boolean classesonly, Object[] args) {
-            this(id, classesonly, args, getLoader());
-        }
-
-        public DefaultLoader(String id, boolean classesonly, Object[] args, ClassLoader loader) {
-            this.loader = loader != null ? loader : getLoader();
+        public DefaultLoader(
+          String id, 
+          boolean classesonly, 
+          Object[] args) {
+            this(
+              id, 
+              classesonly, 
+              args, 
+              getLoader());
+        }
+
+        public DefaultLoader(
+          String id, 
+          boolean classesonly, 
+          Object[] args, 
+          @Nullable ClassLoader loader) {
+            this.loader = 
+              loader != null ? 
+                loader : getLoader();
             this.id = id;
             this.args = args;
             this.iterator = init(classesonly);
         }
 
-        public DefaultLoader(Class<T> _class, boolean classesonly, Object[] args, ClassLoader loader) {
-          this(_class.getName(), classesonly, args, loader);
+        public DefaultLoader(
+          Class<T> _class, 
+          boolean classesonly, 
+          Object[] args, 
+          @Nullable ClassLoader loader) {
+            this(
+              _class.getName(), 
+              classesonly, 
+              args, 
+              loader);
         }
         
-        public DefaultLoader(Class<T> _class, boolean classesonly, Object[] args) {
-          this(_class.getName(), classesonly, args);
+        public DefaultLoader(
+          Class<T> _class, 
+          boolean classesonly, 
+          Object[] args) {
+            this(
+              _class.getName(), 
+              classesonly, 
+              args);
         }
         
         private Iterator<T> init(boolean classesonly) {
-            try {
-                Set<Iterator<T>> list = new HashSet<Iterator<T>>();
-                Enumeration<URL> e = locateResources("META-INF/services/" + id, //$NON-NLS-1$ 
-                                                     loader,
-                                                     Discover.class);
-                while (e.hasMoreElements()) {
-                    Iterator<T> i =
-                        new DefaultLoaderIterator<T>(loader, e.nextElement().openStream(), classesonly, args);
-                    list.add(i);
-                }
-                return Iterators.concat(list.iterator());
-            } catch (Throwable t) {
-                throw new RuntimeException(t);
-            }
+          try {
+            Set<Iterator<T>> list = new HashSet<Iterator<T>>();
+            Enumeration<URL> e = locateResources(
+              "META-INF/services/" + id, //$NON-NLS-1$ 
+              loader,
+              Discover.class);
+              while (e.hasMoreElements()) {
+                Iterator<T> i =
+                  new DefaultLoaderIterator<T>(
+                    loader, 
+                    e.nextElement().openStream(), 
+                    classesonly, 
+                    args);
+                list.add(i);
+              }
+            return Iterators.concat(list.iterator());
+          } catch (Throwable t) {
+            throw ExceptionHelper.propogate(t);
+          }
         }
-
         public Iterator<T> iterator() {
-            return iterator;
+          return iterator;
         }
     }
 
-    public static class DefaultLoaderIterator<T> extends LineReaderLoaderIterator<T> {
-        public DefaultLoaderIterator(ClassLoader cl, InputStream in, boolean classesonly, Object[] args) {
-            super(cl, in, classesonly, args);
-        }
+    public static class DefaultLoaderIterator<T> 
+      extends LineReaderLoaderIterator<T> {
+      public DefaultLoaderIterator(
+        ClassLoader cl, 
+        InputStream in, 
+        boolean classesonly, 
+        Object[] args) {
+          super(cl, in, classesonly, args);
+      }
 
-        public T next() {
-            try {
-                if (!hasNext())
-                    return null;
-                return create(read(), args);
-            } catch (Throwable t) {
-                return null;
-            }
-        }
-
-        protected T create(String spec, Object[] args) {
-            try {
-                return (T)load(cl, spec, classesonly, args);
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Throwable t) {
-                throw new RuntimeException(t);
-            }
+      public T next() {
+        try {
+          if (!hasNext())
+            return null;
+          return create(read(), args);
+        } catch (Throwable t) {
+           return null;
         }
-    }
+      }
 
-    private static <T> T load(ClassLoader loader, String spec, boolean classesonly, Object[] args) throws Exception {
-        if (classesonly) {
-            return (T)getClass(loader, spec);
-        } else {
-            Class<T> _class = getClass(loader, spec);
-            Class<?>[] types = new Class<?>[args != null ? args.length : 0];
-            if (args != null) {
-                for (int n = 0; n < args.length; n++) {
-                    types[n] = args[n].getClass();
-                }
-                return _class.getConstructor(types).newInstance(args);
-            } else {
-                return _class.newInstance();
-            }
+      protected T create(
+        String spec, 
+        Object[] args) {
+          try {
+            return Discover.<T>load(cl, spec, classesonly, args);
+          } catch (Throwable t) {
+            throw ExceptionHelper.propogate(t);
+          }
+      }
+    }
+
+    private static <T> T load(
+      ClassLoader loader,
+      String spec, 
+      boolean classesonly, 
+      Object[] args) 
+        throws Exception {
+        if (classesonly)
+          return (T)getClass(loader, spec);
+        else {
+          Class<T> _class = 
+            getClass(loader, spec);
+          return MoreFunctions
+            .<T>createInstance(_class)
+            .apply(args);
         }
     }
 
-    private static <T> Class<T> getClass(ClassLoader loader, String spec) {
+    private static <T> Class<T> getClass(
+      ClassLoader loader, 
+      String spec) {
         Class<T> c = null;
         try {
-            c = (Class<T>)loader.loadClass(spec);
+          c = (Class<T>)loader.loadClass(spec);
         } catch (ClassNotFoundException e) {
-            try {
-                // try loading the class from the Discover class loader
-                // if the loader failed.
-                c = (Class<T>)Discover.class.getClassLoader().loadClass(spec);
-            } catch (ClassNotFoundException e1) {
-                // throw the original exception
-                throw new RuntimeException(e);
-            }
+          try {
+            // try loading the class from the Discover class loader
+            // if the loader failed.
+            c = (Class<T>)Discover.class.getClassLoader().loadClass(spec);
+          } catch (ClassNotFoundException e1) {
+            // throw the original exception
+            throw new RuntimeException(e);
+          }
         }
         return c;
     }
 
-    public static abstract class LineReaderLoaderIterator<T> extends LoaderIterator<T> {
+    public static abstract class LineReaderLoaderIterator<T> 
+      extends LoaderIterator<T> {
         private BufferedReader buf = null;
         private String line = null;
         protected final Object[] args;
         protected final boolean classesonly;
 
-        protected LineReaderLoaderIterator(ClassLoader cl, InputStream in, boolean classesonly, Object[] args) {
+        protected LineReaderLoaderIterator(
+          ClassLoader cl, 
+          InputStream in, 
+          boolean classesonly, 
+          Object[] args) {
             super(cl);
             this.args = args;
             this.classesonly = classesonly;
             try {
-                InputStreamReader reader = new InputStreamReader(in, "UTF-8");
-                buf = new BufferedReader(reader);
-                line = readNext();
+              InputStreamReader reader = 
+                new InputStreamReader(in, "UTF-8");
+              buf = new BufferedReader(reader);
+              line = readNext();
             } catch (Throwable t) {
-                throw new RuntimeException(t);
+              throw ExceptionHelper.propogate(t);
             }
         }
 
         public boolean hasNext() {
-            return line != null;
+          return line != null;
         }
 
         protected String readNext() {
-            try {
-                String line = null;
-                while ((line = buf.readLine()) != null) {
-                    line = line.trim();
-                    if (!line.startsWith("#"))break; //$NON-NLS-1$
-                }
-                return line;
-            } catch (Throwable t) {
-                throw new RuntimeException(t);
+          try {
+            String line = null;
+            while ((line = buf.readLine()) != null) {
+              line = line.trim();
+              if (!line.startsWith("#"))break; //$NON-NLS-1$
             }
+            return line;
+          } catch (Throwable t) {
+            throw new RuntimeException(t);
+          }
         }
 
         protected String read() {
-            String val = line;
-            line = readNext();
-            return val;
+          String val = line;
+          line = readNext();
+          return val;
         }
     }
 
-    public static abstract class LoaderIterator<T> implements Iterator<T> {
+    public static abstract class LoaderIterator<T> 
+      implements Iterator<T> {
         protected final ClassLoader cl;
-
         protected LoaderIterator(ClassLoader cl) {
-            this.cl = cl;
-        }
-
-        public void remove() {
+          this.cl = cl;
         }
+        public void remove() {}
     }
 
-    public static URL locateResource(String id, ClassLoader loader, Class<?> callingClass) {
+    public static URL locateResource(
+      String id, 
+      ClassLoader loader, 
+      Class<?> callingClass) {
         URL url = loader.getResource(id);
         if (url == null && id.startsWith("/"))
-            url = loader.getResource(id.substring(1));
+          url = loader.getResource(id.substring(1));
         if (url == null)
-            url = locateResource(id, Discover.class.getClassLoader(), callingClass);
+          url = locateResource(id, Discover.class.getClassLoader(), callingClass);
         if (url == null && callingClass != null)
-            url = locateResource(id, callingClass.getClassLoader(), null);
-        if (url == null) {
-            url = callingClass.getResource(id);
-        }
-        if ((url == null) && id.startsWith("/")) {
-            url = callingClass.getResource(id.substring(1));
-        }
+          url = locateResource(id, callingClass.getClassLoader(), null);
+        if (url == null)
+          url = callingClass.getResource(id);
+        if ((url == null) && id.startsWith("/"))
+          url = callingClass.getResource(id.substring(1));
         return url;
     }
 
-    public static Enumeration<URL> locateResources(String id, ClassLoader loader, Class<?> callingClass)
+    public static Enumeration<URL> locateResources(
+      String id, 
+      ClassLoader loader, 
+      Class<?> callingClass)
         throws IOException {
-        Enumeration<URL> urls = loader.getResources(id);
-        if (urls == null && id.startsWith("/"))
-            urls = loader.getResources(id.substring(1));
-        if (urls == null)
-            urls = locateResources(id, Discover.class.getClassLoader(), callingClass);
-        if (urls == null)
-            urls = locateResources(id, callingClass.getClassLoader(), callingClass);
-        return urls;
+      Enumeration<URL> urls = loader.getResources(id);
+      if (urls == null && id.startsWith("/"))
+        urls = loader.getResources(id.substring(1));
+      if (urls == null)
+        urls = locateResources(id, Discover.class.getClassLoader(), callingClass);
+      if (urls == null)
+        urls = locateResources(id, callingClass.getClassLoader(), callingClass);
+      return urls;
     }
 
-    public static InputStream locateResourceAsStream(String resourceName, ClassLoader loader, Class<?> callingClass) {
+    public static InputStream locateResourceAsStream(
+      String resourceName, 
+      ClassLoader loader, 
+      Class<?> callingClass) {
         URL url = locateResource(resourceName, loader, callingClass);
         try {
-            return (url != null) ? url.openStream() : null;
+          return (url != null) ? url.openStream() : null;
         } catch (IOException e) {
-            return null;
+          return null;
         }
     }
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Localizer.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Localizer.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Localizer.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Localizer.java Mon Oct 31 17:42:21 2011
@@ -20,17 +20,19 @@ package org.apache.abdera2.common;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
+import javax.annotation.Nullable;
+
 /**
  * Wraps ResourceBundle with a couple of additional, useful methods. Used for l10n
  */
 public final class Localizer {
 
-    private static Localizer instance = null;
+    private static Localizer instance;
 
     public static synchronized Localizer getInstance() {
-        if (instance == null)
-            instance = new Localizer();
-        return instance;
+      if (instance == null)
+        instance = new Localizer();
+      return instance;
     }
 
     public static synchronized void setInstance(Localizer localizer) {
@@ -41,7 +43,7 @@ public final class Localizer {
         return getInstance().getValue(key);
     }
 
-    public static String get(String key, String defaultValue) {
+    public static String get(String key, @Nullable String defaultValue) {
         return getInstance().getValue(key, defaultValue);
     }
 
@@ -55,32 +57,58 @@ public final class Localizer {
     private final ResourceBundle bundle;
 
     public Localizer() {
-        this(Locale.getDefault(), Thread.currentThread().getContextClassLoader());
+        this(
+          Locale.getDefault(), 
+          Thread.currentThread().getContextClassLoader());
     }
 
-    public Localizer(Locale locale, ClassLoader loader) {
-        this(initResourceBundle(DEFAULT_BUNDLE, locale, loader), locale);
+    public Localizer(
+      @Nullable Locale locale, 
+      @Nullable ClassLoader loader) {
+        this(initResourceBundle(
+          DEFAULT_BUNDLE, 
+          locale, 
+          loader), 
+          locale);
     }
 
     public Localizer(String bundle) {
-        this(initResourceBundle(bundle, Locale.getDefault(), Thread.currentThread().getContextClassLoader()));
-    }
-
-    public Localizer(String bundle, Locale locale) {
-        this(initResourceBundle(bundle, locale, Thread.currentThread().getContextClassLoader()));
-    }
-
-    public Localizer(ResourceBundle bundle) {
-        this(bundle, bundle.getLocale());
-    }
-
-    public Localizer(ResourceBundle bundle, Locale locale) {
+        this(initResourceBundle(
+          bundle, 
+          Locale.getDefault(), 
+          Thread.currentThread().getContextClassLoader()));
+    }
+
+    public Localizer(
+      String bundle, 
+      @Nullable Locale locale) {
+      this(initResourceBundle(
+        bundle, 
+        locale, 
+        Thread.currentThread().getContextClassLoader()));
+    }
+
+    public Localizer(
+      ResourceBundle bundle) {
+      this(
+        bundle, 
+        bundle.getLocale());
+    }
+
+    public Localizer(
+      ResourceBundle bundle, 
+      Locale locale) {
         this.bundle = bundle;
         this.locale = locale;
     }
 
-    private static ResourceBundle initResourceBundle(String bundle, Locale locale, ClassLoader loader) {
+    private static ResourceBundle initResourceBundle(
+      String bundle, 
+      @Nullable Locale locale, 
+      @Nullable ClassLoader loader) {
         try {
+          if (locale == null) locale = Locale.getDefault();
+          if (loader == null) loader = Thread.currentThread().getContextClassLoader();
             return ResourceBundle.getBundle(bundle, locale, loader);
         } catch (Exception e) {
             return null;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/AnnoUtil.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/AnnoUtil.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/AnnoUtil.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/AnnoUtil.java Mon Oct 31 17:42:21 2011
@@ -30,7 +30,7 @@ public final class AnnoUtil {
   /**
    * Retrieves the value of the Name attribute from the specified 
    * item. If the item is an instance object, the name is pulled from it's
-   * Class.
+   * Class. If item is null, returns null.
    */
   public static String getName(Object item) {
     if (item == null) return null;
@@ -46,6 +46,7 @@ public final class AnnoUtil {
    * Retrieve the default implementation for the specified Class.
    */
   public static String getDefaultImplementation(Class<?> _class) {
+    if (_class == null) return null;
     String _default = null;
     if (_class.isAnnotationPresent(DefaultImplementation.class)) {
       DefaultImplementation di = 
@@ -74,17 +75,15 @@ public final class AnnoUtil {
    * @return A List of Namespace URIs Supported by this Extension
    */
   public static Set<String> getNamespaces(Object obj) {
-    if (obj == null) return Collections.emptySet();
+    if (obj == null) return Collections.<String>emptySet();
     Class<?> _class = 
       obj instanceof Class ? (Class<?>)obj :
       obj.getClass();
     Set<String> ns = new HashSet<String>();
-    if (_class.isAnnotationPresent(Namespace.class)) {
-      Namespace nsa = _class.getAnnotation(Namespace.class);
-      for (String n : nsa.value())
+    if (_class.isAnnotationPresent(Namespace.class))
+      for (String n : _class.getAnnotation(Namespace.class).value())
         ns.add(n);
-    }
-    return ns;
+    return Collections.unmodifiableSet(ns);
   }
 
   /**
@@ -100,17 +99,17 @@ public final class AnnoUtil {
    * Retrieve a javax.xml.namespace.QName from a class using the QName annotation.
    */
   public static QName qNameFromAnno(org.apache.abdera2.common.anno.QName impl) {
+    if (impl == null) return null;
     QName result = null;
     String name = impl.value();
       String ns = impl.ns();
       String pfx = impl.pfx();
-      if (pfx != null && pfx.length() > 0) {
+      if (pfx != null && pfx.length() > 0)
         result = new QName(ns,name,pfx);
-      } else if (ns != null && ns.length() > 0) {
+      else if (ns != null && ns.length() > 0)
         result = new QName(ns,name);
-      } else if (name != null && name.length() > 0) {
+      else if (name != null && name.length() > 0)
         result = new QName(name);
-      };
     return result;
   }
   
@@ -120,10 +119,11 @@ public final class AnnoUtil {
    */
   public static QName getQName(Object obj) {
     if (obj == null) return null;
-    Class<?> _class = obj instanceof Class ? (Class<?>)obj : obj.getClass();
-    if (_class.isAnnotationPresent(org.apache.abdera2.common.anno.QName.class)) {
+    Class<?> _class = 
+      obj instanceof Class ? 
+        (Class<?>)obj : obj.getClass();
+    if (_class.isAnnotationPresent(org.apache.abdera2.common.anno.QName.class))
       return qNameFromAnno(_class.getAnnotation(org.apache.abdera2.common.anno.QName.class));
-    }
     return null;
   }
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Context.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Context.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Context.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Context.java Mon Oct 31 17:42:21 2011
@@ -6,6 +6,12 @@ import static java.lang.annotation.Reten
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 
+/**
+ * The Context Annotation is intended for use with classes 
+ * with the URITemplate annotation to establish a static
+ * default context. Each Context Annotation contains a 
+ * list of static Param annotations
+ */
 @Retention(RUNTIME)
 @Target( {TYPE})
 public @interface Context {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Name.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Name.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Name.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Name.java Mon Oct 31 17:42:21 2011
@@ -30,7 +30,5 @@ import java.lang.annotation.Target;
 @Target( {TYPE,FIELD,METHOD})
 @Inherited
 public @interface Name {
-
   String value();
-  
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Version.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Version.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Version.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Version.java Mon Oct 31 17:42:21 2011
@@ -28,9 +28,7 @@ import java.lang.annotation.Target;
 @Target( {TYPE})
 @Inherited
 public @interface Version {
-
   String value(); // Version Number
   String name();  // App Name
   String uri();   // App URI
-  
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java Mon Oct 31 17:42:21 2011
@@ -15,6 +15,7 @@ import org.joda.time.Interval;
 
 import static org.apache.abdera2.common.misc.Comparisons.*;
 import com.google.common.base.Equivalence;
+import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.base.Supplier;
 import com.google.common.collect.Range;
@@ -24,29 +25,72 @@ public final class DateTimes {
 
   private DateTimes() {}
   
+  /**
+   * Simple Function that creates a DateTime from an object..
+   * the input can be a string, a long, a java.util.Date, 
+   * a java.util.Calendar or another DateTime. This is 
+   * mainly a convenience wrapper for the default constructor
+   */
+  public static final Function<Object,DateTime> parser = 
+    new Function<Object,DateTime>() {
+      public DateTime apply(Object input) {
+        return new DateTime(input);
+      }
+  };
+  
+  /**
+   * Simple Function that formats a DateTime object to 
+   * ISO8601-compliant string. This is mainly just a 
+   * convenience wrapper.
+   */
+  public static final Function<DateTime,String> formatter = 
+    new Function<DateTime,String>() {
+      public String apply(DateTime input) {
+        return format(input);
+      }
+  };
+  
   private static final DateTimeFormatter DTF =
     ISODateTimeFormat.dateTime();
   
+  /**
+   * Formats the current date/time to string using the default timezone
+   */
   public static String formatNow() {
     return DateTime.now().toString(DTF);
   }
   
+  /**
+   * Formats the given date/time to string
+   */
   public static String format(String dateTime) {
     return DTF.print(new DateTime(dateTime));
   }
   
+  /**
+   * Formats the given date/time to string
+   */
   public static String format(DateTime dateTime) {
     return DTF.print(dateTime);
   }
   
+  /**
+   * Formats the given date/time to string
+   */
   public static String format(Date date) {
     return DTF.print(new DateTime(date));
   }
   
+  /**
+   * Formats the given date/time to string
+   */
   public static String format(Calendar cal) {
     return DTF.print(new DateTime(cal));
   }
   
+  /**
+   * Formats the given date/time to string
+   */
   public static String format(long ms) {
     return DTF.print(ms);
   }
@@ -55,18 +99,30 @@ public final class DateTimes {
     return DateTime.parse(t).toDate();
   }
   
+  /**
+   * Converts the given DateTime to the UTC TimeZone
+   */
   public static DateTime toUTC(DateTime dt) {
     return dt.toDateTime(DateTimeZone.UTC);
   }
   
+  /**
+   * Converts the given DateTime to the given TimeZone
+   */
   public static DateTime toTimeZone(DateTime dt, TimeZone tz) {
     return dt.toDateTime(DateTimeZone.forTimeZone(tz));
   }
   
+  /**
+   * Converts the given DateTime to the given TimeZone
+   */
   public static DateTime toTimeZone(DateTime dt, String id) {
     return dt.toDateTime(DateTimeZone.forID(id));
   }
   
+  /**
+   * Use the DateTimeBuilder to generate a DateTime object
+   */
   public static DateTimeBuilder makeDateTime() {
     return new DateTimeBuilder();
   }
@@ -230,6 +286,9 @@ public final class DateTimes {
     }
   }
   
+  /**
+   * Convenience Utility for Comparing DateTime instances
+   */
   public static abstract class DateTimeComparator<X> implements Comparator<X> {
     public int innerCompare(DateTime d1, DateTime d2) {
       if (onlySecondIsNull(d1,d2)) return 1;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java Mon Oct 31 17:42:21 2011
@@ -21,9 +21,9 @@ import java.io.ByteArrayOutputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -125,7 +125,7 @@ public class Authentication implements I
     private String scheme;
     private String b64token;
     private Map<String,String> params = 
-      new HashMap<String,String>();
+      new LinkedHashMap<String,String>();
     private Set<String> quoted = 
       new HashSet<String>();
     
@@ -145,7 +145,7 @@ public class Authentication implements I
       return this;
     }
     
-    public Builder isQuoted(String name) {
+    public Builder quoted(String name) {
       quoted.add(name);
       return this;
     }
@@ -170,7 +170,7 @@ public class Authentication implements I
   private final String scheme;
   private final String b64token;
   private final Map<String,String> params = 
-    new HashMap<String,String>();
+    new LinkedHashMap<String,String>();
   private final Set<String> quoted = 
     new HashSet<String>();
     
@@ -234,14 +234,13 @@ public class Authentication implements I
         String val = getParam(param);
         buf.append(param);
         boolean always = is_always_quoted(param) || isquoted(param);
-        if (Profile.TOKEN.check(val) && !always) {
+        if (Profile.TOKEN.check(val) && !always)
           buf.append('*')
              .append('=')
              .append(Codec.encode(val,Codec.STAR));
-        } else {
+        else
           buf.append('=')
              .append(always?quoted(val,true):quotedIfNotToken(val));
-        }
       }
     }
     return buf.toString();

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControlUtil.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControlUtil.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControlUtil.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControlUtil.java Mon Oct 31 17:42:21 2011
@@ -105,7 +105,7 @@ public final class CacheControlUtil {
                  .append('"')
                  .append(val)
                  .append('"');
-            }
+          }
         }
         return buf.toString();
     }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java Mon Oct 31 17:42:21 2011
@@ -30,6 +30,7 @@ import org.apache.abdera2.common.text.Ur
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
+import static com.google.common.base.Preconditions.*;
 
 /**
  * Implements an EntityTag.
@@ -39,25 +40,22 @@ public class EntityTag 
 
     private static final long serialVersionUID = 1559972888659121461L;
 
-    private static final String INVALID_ENTITY_TAG = "Invalid entity tag";
-
     public static final EntityTag WILD = new EntityTag("*");
 
     public static EntityTag parse(String entity_tag) {
-      if (entity_tag == null || entity_tag.length() == 0)
-          throw new IllegalArgumentException("Invalid");
+      checkNotNull(entity_tag);
+      checkArgument(entity_tag.length() > 0, "Invalid");
       int l = entity_tag.length()-1;
-      boolean wild = entity_tag.charAt(0) == '*' && 
-                     l == 0;
+      boolean wild = 
+        entity_tag.charAt(0) == '*' && l == 0;
       if (wild) return EntityTag.WILD;
       boolean weak = (entity_tag.charAt(0) == 'W' || 
                      entity_tag.charAt(0) == 'w');
-      if (weak && entity_tag.charAt(1) != '/')
-        throw new IllegalArgumentException("Invalid");
+      checkArgument(!(weak && entity_tag.charAt(1) !='/'),"Invalid");
       int pos = weak?2:0;
-      if (entity_tag.charAt(pos) != '"' || 
-          entity_tag.charAt(l) != '"')
-        throw new IllegalArgumentException("Invalid");
+      checkArgument(
+        entity_tag.charAt(pos) == '"' && 
+        entity_tag.charAt(l) == '"',"Invalid");
       String tag = entity_tag.substring(pos+1,l);
       return new EntityTag(tag, weak, false);
     }
@@ -65,14 +63,13 @@ public class EntityTag 
     public static Iterable<EntityTag> parseTags(String entity_tags) {
         if (entity_tags == null || 
             entity_tags.length() == 0)
-            return Collections.emptyList();
+          return Collections.emptyList();
         String[] tags = 
           entity_tags.split("((?<=\")\\s*,\\s*(?=([wW]/)?\"|\\*))");
         List<EntityTag> etags = 
           new ArrayList<EntityTag>();
-        for (String tag : tags) {
+        for (String tag : tags)
             etags.add(EntityTag.parse(tag.trim()));
-        }
         return etags;
     }
 
@@ -155,10 +152,9 @@ public class EntityTag 
             return (tag1 == null) ? true : false;
         if (tag1.isWild() && !empty(tags))
             return true;
-        for (EntityTag tag : tags) {
-            if (tag1.equals(tag,weak) || tag.isWild())
-                return true;
-        }
+        for (EntityTag tag : tags)
+          if (tag1.equals(tag,weak) || tag.isWild())
+            return true;
         return false;
     }
 
@@ -229,7 +225,7 @@ public class EntityTag 
         EntityTag tag, 
         String label, 
         String... labels) {
-        if (label == null || tag == null | tag.isWild()) 
+        if (label == null || tag == null || tag.isWild()) 
           throw new IllegalArgumentException();
         StringBuilder buf = 
           new StringBuilder(tag.getTag());
@@ -253,8 +249,7 @@ public class EntityTag 
     public EntityTag(String tag, boolean weak) {
         EntityTag etag = attemptParse(tag);
         if (etag == null) {
-            if (tag.indexOf('"') > -1)
-                throw new IllegalArgumentException(INVALID_ENTITY_TAG);
+            checkArgument(tag.indexOf('"') == -1, "Invalid");
             this.tag = tag;
             this.weak = weak;
             this.wild = tag.equals("*");

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java Mon Oct 31 17:42:21 2011
@@ -15,6 +15,7 @@ import javax.activation.MimeType;
 
 import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.lang.Lang;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.common.text.CharUtils;
 import org.apache.abdera2.common.text.Codec;
 
@@ -155,11 +156,7 @@ public class WebLink implements Serializ
     }
     
     public Builder mediaType(String type) {
-      try {
-        this.mediaType = new MimeType(type);
-      } catch (javax.activation.MimeTypeParseException e) {
-        throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
-      }
+      this.mediaType = MimeTypeHelper.create(type);
       return this;
     }
     
@@ -206,7 +203,7 @@ public class WebLink implements Serializ
   public WebLink(IRI iri, String rel) {
     checkNotNull(iri);
     this.iri = iri.normalize();
-    if (rel != null) this.rel.add(rel); // verify
+    if (rel != null) this.rel.add(rel);
     this.anchor = null;
     this.lang = null;
     this.title = null;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Chain.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Chain.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Chain.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Chain.java Mon Oct 31 17:42:21 2011
@@ -45,9 +45,9 @@ public final class Chain<T,R> 
     }
    
     public R next(T input) {
-        return tasks.hasNext() ? 
-            tasks.next().apply(input, this) : 
-            to.apply(input);
+      return tasks.hasNext() ? 
+        tasks.next().apply(input, this) : 
+        to.apply(input);
     }
 
     public R apply(T input) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java Mon Oct 31 17:42:21 2011
@@ -26,18 +26,18 @@ public class ExceptionHelper {
               new StringBuilder(message);
             if (args.length > 0)
               buf.append(" ");
-            for (Object arg : args) {
+            for (Object arg : args)
               buf.append('[')
                  .append(arg)
                  .append(']');
-            }
-            t =  _class
-              .getConstructor(String.class)
-              .newInstance(buf.toString());
+            t = MoreFunctions
+              .<T>createInstance(
+                _class,
+                buf.toString());
           } else
-            t = _class
-              .getConstructor()
-              .newInstance(); 
+            t = MoreFunctions
+              .<T>createInstance(_class)
+                .apply(null);
         } catch (Throwable e) {
           throw propogate(e);
         }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java Mon Oct 31 17:42:21 2011
@@ -16,7 +16,53 @@ import com.google.common.base.Suppliers;
 import com.google.common.collect.Iterables;
 
 public class MoreFunctions {
- 
+
+  public static <T>T createInstance(Class<T> _class, Object... args) {
+    return MoreFunctions.<T>createInstance(_class).apply(args);
+  }
+  
+  public static <T>T createInstance(Class<T> _class, Class<?>[] types, Object... args) {
+    return MoreFunctions.<T>createInstance(_class,types).apply(args);
+  }
+  
+  public static <T>Function<Object[],T> createInstance(
+    final Class<T> _class,
+    final Class<?>... args) {
+    return new Function<Object[],T>() {
+      public T apply(Object[] input) {
+        try {
+          if (input != null) {
+            return _class.getConstructor(args).newInstance(input);
+          } else {
+            return _class.newInstance();
+          }
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
+  public static <T>Function<Object[],T> createInstance(
+    final Class<T> _class) {
+    return new Function<Object[],T>() {
+      public T apply(Object[] input) {
+        try {
+          if (input != null) {
+            Class<?>[] _types = new Class[input.length];
+            for (int n = 0; n < input.length; n++) 
+              _types[n] = input[n].getClass();
+            return _class.getConstructor(_types).newInstance(input);
+          } else {
+            return _class.newInstance();
+          }
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+    };
+  }
+  
   public static <R extends Initializable>Function<Map<String,Object>,R> discoverInitializable(
     final Class<R> _class) {
       return discoverInitializable(_class,null);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java Mon Oct 31 17:42:21 2011
@@ -20,6 +20,7 @@ package org.apache.abdera2.common.protoc
 import java.lang.reflect.Constructor;
 
 import org.apache.abdera2.common.misc.ExceptionHelper;
+import org.apache.abdera2.common.misc.MoreFunctions;
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
@@ -88,15 +89,20 @@ public abstract class RequestProcessor 
       final WorkspaceManager workspaceManager,
       final Predicate<RequestContext> predicate) {
       try {
-        final Constructor<T> c = 
-          _class.getConstructor(
-            WorkspaceManager.class,
-            CollectionAdapter.class,
+        final Function<Object[],T> c =
+          MoreFunctions.<T>createInstance(
+            _class, 
+            WorkspaceManager.class, 
+            CollectionAdapter.class, 
             Predicate.class);
         return new RequestProcessorSupplier<T>(workspaceManager) {
           public T apply(CollectionAdapter adapter) {
             try {
-              return c.newInstance(workspaceManager,adapter,predicate);
+              return c.apply(
+                MoreFunctions.array(
+                  workspaceManager,
+                  adapter,
+                  predicate));
             } catch (Throwable t) {
               throw ExceptionHelper.propogate(t);
             }
@@ -111,14 +117,18 @@ public abstract class RequestProcessor 
     final Class<T> _class, 
     final WorkspaceManager workspaceManager) {
     try {
-      final Constructor<T> c = 
-        _class.getConstructor(
-          WorkspaceManager.class,
+      final Function<Object[],T> c =
+        MoreFunctions.<T>createInstance(
+          _class, 
+          WorkspaceManager.class, 
           CollectionAdapter.class);
       return new RequestProcessorSupplier<T>(workspaceManager) {
         public T apply(CollectionAdapter adapter) {
           try {
-            return c.newInstance(workspaceManager,adapter);
+            return c.apply(
+              MoreFunctions.array(
+                workspaceManager,
+                adapter));
           } catch (Throwable t) {
             throw ExceptionHelper.propogate(t);
           }

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/SimpleListener.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/SimpleListener.java?rev=1195583&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/SimpleListener.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/SimpleListener.java Mon Oct 31 17:42:21 2011
@@ -0,0 +1,10 @@
+package org.apache.abdera2.common.pusher;
+
+public abstract class SimpleListener<T> 
+  implements Listener<T> {
+
+  public void beforeItems() {}
+
+  public void afterItems() {}
+
+}

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/SimpleListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/model/ElementList.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/model/ElementList.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/model/ElementList.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/model/ElementList.java Mon Oct 31 17:42:21 2011
@@ -36,10 +36,13 @@ import java.util.ListIterator;
  * is consumed as the list is used. The List itself is unmodifiable.
  */
 @SuppressWarnings("unchecked")
-public class ElementList<T extends Element> extends AbstractCollection<T> implements List<T> {
+public class ElementList<T extends Element> 
+  extends AbstractCollection<T> 
+  implements List<T> {
 
     private final Iterator<T> i;
-    private final List<T> buffer = new ArrayList<T>();
+    private final List<T> buffer = 
+      new ArrayList<T>();
 
     public ElementList(Iterator<T> i) {
         this.i = i;

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/AbstractParseFilter.java Mon Oct 31 17:42:21 2011
@@ -20,6 +20,8 @@ package org.apache.abdera2.parser.filter
 import javax.xml.namespace.QName;
 
 import org.apache.abdera2.common.misc.ExceptionHelper;
+import org.apache.abdera2.common.misc.MoreFunctions;
+
 import com.google.common.base.Supplier;
 
 @SuppressWarnings("unchecked")
@@ -101,13 +103,10 @@ public abstract class AbstractParseFilte
       QName attribute) {
       if (!answer && _throw != null) {
         try {
-          throw _throw
-            .getConstructor(
-              QName.class,
-              QName.class)
-            .newInstance(
-              element,
-              attribute);
+          throw MoreFunctions
+            .createInstance(_throw)
+            .apply(MoreFunctions
+               .array(element,attribute));
         } catch (Throwable e) {
           throw ExceptionHelper.propogate(e);
         }

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=1195583&r1=1195582&r2=1195583&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 Mon Oct 31 17:42:21 2011
@@ -7,7 +7,8 @@ import org.apache.abdera2.activities.mod
 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;
+import static org.apache.abdera2.activities.model.Activity.makeActivity;
+import static org.apache.abdera2.activities.model.objects.PersonObject.makePerson;
 
 public class Activities {
 
@@ -15,28 +16,32 @@ public class Activities {
     
     // 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 activity = 
+      makeActivity()
+        .actor(
+          makePerson()
+            .displayName("James")
+            .get())
+        .verb(Verb.FOLLOW)
+        .object(
+          makePerson()
+            .email("john.doe@example.org")
+            .displayName("John Doe")
+            .get())
+        .get();
     
     activity.writeTo(System.out);
     
     System.out.println("\n\n\n");
     
     // Activity Stream
-    Collection<Activity> collection = new Collection<Activity>();
-    collection.addItem(activity);
+    Collection<Activity> collection = 
+      Collection.<Activity>makeCollection()
+        .item(activity)
+        .get();
     
     collection.writeTo(System.out);
     
-    
     System.out.println("\n\n\n");
     
     // Parsing example
@@ -48,7 +53,8 @@ public class Activities {
     collection = IO.get().readCollection(in, "UTF-8");
     
     for (Activity a : collection.getItems()) {
-      System.out.println(String.format("%s [%s] %s", 
+      System.out.println(
+        String.format("%s [%s] %s", 
           a.getActor().getDisplayName(), 
           a.getVerb(), 
           a.getObject().getDisplayName()));

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=1195583&r1=1195582&r2=1195583&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 Mon Oct 31 17:42:21 2011
@@ -13,6 +13,10 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.common.io.Compression.CompressionCodec;
 import org.apache.abdera2.common.security.HashHelper;
 
+
+import static org.apache.abdera2.activities.extra.BinaryObject.makeBinary;
+import static org.apache.abdera2.activities.model.objects.BadgeObject.makeBadge;
+
 /**
  * Illustrates the extension "binary" objectType... this can be useful, 
  * for instance, when attaching arbitrary base64 encoded data to an 
@@ -28,22 +32,23 @@ public class BinaryDataObjectExample {
     URL url = BinaryDataObjectExample.class.getResource("/info.png");
     DataHandler dataHandler = new DataHandler(url); 
     
-    BinaryObject dataObject = new BinaryObject();
-    // set the content.. md5 hash will be calculated and deflate compression used
-    dataObject.setData(
-      dataHandler, 
-      new HashHelper.Md5(), 
-      CompressionCodec.DEFLATE);
-    
-    BadgeObject badge = new BadgeObject();
-    badge.addAttachment(dataObject);
+    BadgeObject badge = 
+      makeBadge()
+        .attachment(
+          makeBinary()
+            .data(
+              dataHandler, 
+              new HashHelper.Md5(), 
+              CompressionCodec.DEFLATE)
+            .get())
+        .get();
     
     // check the round trip //
     StringReader sr = new StringReader(io.write(badge));
     
     badge = io.readObject(sr);
-    
-    dataObject = (BinaryObject) badge.getAttachments().iterator().next();
+ 
+    BinaryObject dataObject = (BinaryObject) badge.getAttachments().iterator().next();
     
     String md5 = dataObject.getProperty("md5");
     HashHelper.Md5 check = new HashHelper.Md5();

Modified: 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=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GeneratorStreamingExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/GeneratorStreamingExample.java Mon Oct 31 17:42:21 2011
@@ -10,8 +10,10 @@ import org.apache.abdera2.activities.mod
 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;
+
+import static org.apache.abdera2.activities.model.Activity.makeActivity;
+import static org.apache.abdera2.activities.model.objects.PersonObject.makePerson;
+import static org.apache.abdera2.activities.model.objects.ServiceObject.makeService;
 
 /**
  * Demonstrates the use of the Generator and CollectionWriter 
@@ -37,18 +39,17 @@ public class GeneratorStreamingExample {
     writer.writeHeader(header);
     
     // Prepare the Activity template
-    PersonObject person = 
-      new PersonObject();
-    Activity template = 
-      Activity.makeActivity()
-        .actor(person)
-        .verb(Verb.POST)
-        .provider(
-          new ServiceObject("My Application"))
-        .displayName("joe")
-        .get();
     Generator<Activity> gen = 
-      template.newGenerator();
+      makeActivity()
+      .actor(makePerson().get())
+      .verb(Verb.POST)
+      .provider(
+        makeService()
+          .displayName("My Application")
+          .get())
+      .displayName("joe")
+      .get()
+      .newGenerator();
     
     // we can now use the Generator to produce 
     // new Activities using the one we just 
@@ -61,12 +62,11 @@ public class GeneratorStreamingExample {
     // same list object, so if the list if modified,
     // all copies generated will reference the 
     // modified list
-    for (int n = 0; n < 10; n++) {
+    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

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/PusherExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/PusherExample.java?rev=1195583&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/PusherExample.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/PusherExample.java Mon Oct 31 17:42:21 2011
@@ -0,0 +1,68 @@
+package org.apache.abdera2.examples.activities;
+
+import static java.lang.String.format;
+import static org.apache.abdera2.activities.model.Activity.makeActivity;
+import static org.apache.abdera2.activities.model.objects.NoteObject.makeNote;
+import static org.apache.abdera2.activities.model.objects.PersonObject.makePerson;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadPoolExecutor;
+
+import org.apache.abdera2.activities.model.Activity;
+import org.apache.abdera2.activities.model.Generator;
+import org.apache.abdera2.activities.model.Verb;
+import org.apache.abdera2.common.pusher.ChannelManager;
+import org.apache.abdera2.common.pusher.Pusher;
+import org.apache.abdera2.common.pusher.Receiver;
+import org.apache.abdera2.common.pusher.SimpleChannelManager;
+import org.apache.abdera2.common.pusher.SimpleListener;
+
+public class PusherExample {
+
+  private static final Generator<Activity> gen = 
+    makeActivity()
+    .actor(makePerson().displayName("joe").get())
+    .verb(Verb.POST)
+    .get()
+    .newGenerator();
+  
+  public static void main(String... args) throws Exception {
+    
+    final ChannelManager cm = new SimpleChannelManager();
+    ThreadPoolExecutor exec = (ThreadPoolExecutor) Executors.newCachedThreadPool();
+    final CountDownLatch latch = new CountDownLatch(3);
+    exec.execute(
+      new Runnable() {
+        public void run() {
+          Receiver<Activity> r = cm.getReceiver("foo");
+          r.startListening(
+            new SimpleListener<Activity>() {
+              public void onItem(Activity t) {
+                System.out.println(t.getObject().getDisplayName());
+                latch.countDown();
+              }
+            }
+          );
+        }
+      }
+    );
+    
+    Pusher<Activity> pusher = cm.getPusher("foo");
+    for (int n = 0; n < 3; n++) 
+      pusher.push(
+        gen.startNew()
+          .set("object",
+            makeNote()
+              .displayName(format("My note #%d",n+1))
+              .get())
+          .complete()
+        );
+    
+    latch.await();
+    cm.shutdown();
+    exec.shutdown();
+    
+  }
+  
+}

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

Modified: 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=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ReadingListExample.java Mon Oct 31 17:42:21 2011
@@ -1,13 +1,16 @@
 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;
+
+import static org.apache.abdera2.activities.model.Activity.makeActivity;
+import static org.apache.abdera2.activities.model.objects.PersonObject.makePerson;
+import static org.apache.abdera2.activities.extra.BookObject.makeBook;
+import static org.apache.abdera2.activities.model.Collection.makeCollection;
 
 /**
  * Example that shows a simple practical use of an activity stream
@@ -24,39 +27,44 @@ public class ReadingListExample {
     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();
+      makeActivity()
+        .actor(
+          makePerson()
+            .displayName("James")
+            .get())
+        .get().newGenerator();
+
+    Collection.CollectionGenerator<Activity> builder = 
+      makeCollection();
     
     // Add a book we want to read
-    BookObject book1 = 
-      new BookObject("The Cat in the Hat");
-    stream.addItem(
+    builder.item(
       gen.startNew()
          .set("verb", Verb.SAVE)
-         .set("object", book1)
+         .set("object", 
+           makeBook()
+             .displayName("The Cat in the Hat")
+             .get())
          .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(
+    builder.item(
       gen.startNew()
          .set("verb", Extra.READ)
-         .set("object", book2)
+         .set("object", 
+           makeBook()
+             .displayName("Meditations on the Method")
+             .author(
+               makePerson()
+                 .displayName("Rene Descartes")
+                 .get())
+             .get())
          .set("format", Extra.HARDCOVER())
          .complete());
     
-    stream.writeTo(io,System.out);
+    builder.get().writeTo(io,System.out);
     
   }
   

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/VersionControlExample.java Mon Oct 31 17:42:21 2011
@@ -7,81 +7,87 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.Generator;
 import org.apache.abdera2.activities.model.Verb;
 import org.apache.abdera2.activities.model.objects.FileObject;
-import org.apache.abdera2.activities.model.objects.PersonObject;
+
+import static org.apache.abdera2.activities.model.Collection.makeCollection;
+import static org.apache.abdera2.activities.model.Activity.makeActivity;
+import static org.apache.abdera2.activities.model.objects.PersonObject.makePerson;
+import static org.apache.abdera2.activities.model.objects.FileObject.makeFile;
+import static org.apache.abdera2.activities.extra.VersionObject.makeVersion;
 
 public class VersionControlExample {
 
   public static void main(String... args) throws Exception {
-    
-    Collection<Activity> stream = 
-      new Collection<Activity>();
-    
-    Activity template = 
-      new Activity();
-    PersonObject actor = 
-      new PersonObject();
-    actor.setDisplayName("James");
-    template.setActor(actor);
-    
+        
     Generator<Activity> gen = 
-      template.newGenerator();
+      makeActivity()
+      .actor(
+        makePerson()
+          .displayName("James")
+          .get())
+      .get()
+      .newGenerator();
     
+    Collection.CollectionGenerator<Activity> builder = 
+      makeCollection();
     
     // first, indicate that we created a document
+    FileObject file = 
+      makeFile()
+        .id("http://example.org/presentation.ppt")
+        .displayName("presentation.ppt")
+        .get();
     
-    FileObject file = new FileObject();
-    file.setDisplayName("presentation.ppt");
-    file.setId("http://example.org/presentation.ppt");
-    
-    stream.addItem(
+    builder.item(
       gen.startNew()
-         .set("object", file)
-         .set("verb", Verb.POST)
-         .complete());
+        .set("object", file)
+        .set("verb", Verb.POST)
+        .complete());
     
     // second, indicate that a new version was created
-    VersionObject version = new VersionObject();
-    version.setOf(file);
-    version.setMajor("2");
+    VersionObject version = 
+      makeVersion()
+        .of(file)
+        .major("2")
+        .get();
     
-    stream.addItem(
+    builder.item(
       gen.startNew() 
          .set("object", version)
          .set("verb", Verb.POST)
          .complete());
     
     // whoops, the boss rejected the new version
-    stream.addItem(
+    builder.item(
       gen.startNew()
          .set("object", version)
          .set("verb", Extra.REJECT)
-         .set("actor", new PersonObject("The Boss"))
+         .set("actor", makePerson().displayName("The Boss").get())
          .set("summary", "This version is missing something")
          .complete());
     
     // create a new version to deal with the bosses concerns
     VersionObject old = version;
-    version = new VersionObject();
-    version.setOf(file);
-    version.setMajor("3");
-    version.setPreviousVersion(old);
+    version = makeVersion()
+      .of(file)
+      .major("3")
+      .previous(old)
+      .get();
     
-    stream.addItem(
+    builder.item(
         gen.startNew() 
            .set("object", version)
            .set("verb", Verb.POST)
            .complete());
     
     // the boss approves the new version
-    stream.addItem(
+    builder.item(
       gen.startNew()
          .set("object", version)
          .set("verb", Extra.APPROVE)
-         .set("actor", new PersonObject("The Boss"))
+         .set("actor", makePerson().displayName("The Boss").get())
          .complete());
     
-    
-    stream.writeTo(System.out);
+    builder.get().writeTo(System.out);
   }
   
 }

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/serializer/ObjectResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/serializer/ObjectResponseContext.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/serializer/ObjectResponseContext.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/serializer/ObjectResponseContext.java Mon Oct 31 17:42:21 2011
@@ -20,6 +20,8 @@ package org.apache.abdera2.ext.serialize
 import java.io.IOException;
 import java.lang.reflect.AccessibleObject;
 import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.misc.ExceptionHelper;
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.ext.serializer.annotation.EntityTag;
 import org.apache.abdera2.ext.serializer.annotation.LastModified;
 import org.apache.abdera2.ext.serializer.annotation.MediaType;
@@ -123,19 +125,28 @@ public class ObjectResponseContext exten
 
     @Override
     protected void writeTo(StreamWriter sw) throws IOException {
-        SerializationContext context = newSerializationContext(getAbdera(), conventions, sw);
+        SerializationContext context = 
+          newSerializationContext(getAbdera(), conventions, sw);
         sw.startDocument();
         context.serialize(object, objectContext);
         sw.endDocument();
     }
 
-    private SerializationContext newSerializationContext(Abdera abdera, Conventions conventions, StreamWriter sw) {
+    private SerializationContext newSerializationContext(
+      Abdera abdera, 
+      Conventions conventions, 
+      StreamWriter sw) {
         try {
-            return context.getConstructor(Abdera.class, Conventions.class, StreamWriter.class).newInstance(abdera,
-                                                                                                           conventions,
-                                                                                                           sw);
+          return MoreFunctions
+            .createInstance(
+              context,
+              Abdera.class,
+              Conventions.class,
+              StreamWriter.class)
+                .apply(MoreFunctions
+                  .array(abdera,conventions,sw));
         } catch (Exception e) {
-            throw new RuntimeException(e);
+          throw ExceptionHelper.propogate(e);
         }
     }
 }

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubProvider.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubProvider.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubProvider.java Mon Oct 31 17:42:21 2011
@@ -22,9 +22,9 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.TargetType;
 
 /**
- * Providers are responsible for processing all requests to the Atompub server.<br>
- * Actual request processing is delegated to {@link AtompubRequestProcessor} implementations, depending on the request
- * {@link TargetType}.
+ * Providers are responsible for processing all requests to the Atompub 
+ * server. Actual request processing is delegated to {@link RequestProcessor} 
+ * implementations, depending on the request {@link TargetType}.
  */
 public interface AtompubProvider extends Provider {
 

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubResponseContext.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubResponseContext.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubResponseContext.java Mon Oct 31 17:42:21 2011
@@ -24,7 +24,8 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.writer.Writer;
 
 /**
- * The ResponseContext encapsulates a server response
+ * Extends the core ResponseContext object with methods used to 
+ * output Atom data using a specific Abdera Writer instance.
  */
 public interface AtompubResponseContext extends ResponseContext {
 

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubServiceManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubServiceManager.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubServiceManager.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/AtompubServiceManager.java Mon Oct 31 17:42:21 2011
@@ -26,9 +26,7 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.protocol.server.impl.DefaultAtompubProvider;
 
 /**
- * The ServiceManager is used by the AbderaServlet to bootstrap the server 
- * instance. There should be little to no reason why an end user would need 
- * to use this class directly.
+ * The ServiceManager is used by the AbderaServlet to bootstrap the server instance.
  */
 public class AtompubServiceManager 
   extends AbstractServiceManager {

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/EntityProviderResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/EntityProviderResponseContext.java?rev=1195583&r1=1195582&r2=1195583&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/EntityProviderResponseContext.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/EntityProviderResponseContext.java Mon Oct 31 17:42:21 2011
@@ -26,23 +26,33 @@ import org.apache.abdera2.writer.StreamW
 /**
  * StreamWriterResponseContext implementation based on the EntityProvider interface
  */
-public class EntityProviderResponseContext extends StreamWriterResponseContext {
+public class EntityProviderResponseContext 
+  extends StreamWriterResponseContext {
 
     private final EntityProvider provider;
 
-    public EntityProviderResponseContext(EntityProvider provider, Abdera abdera, String encoding, String sw) {
+    public EntityProviderResponseContext(
+      EntityProvider provider, 
+      Abdera abdera, 
+      String encoding, 
+      String sw) {
         super(abdera, encoding, sw);
         this.provider = provider;
         init();
     }
 
-    public EntityProviderResponseContext(EntityProvider provider, Abdera abdera, String encoding) {
+    public EntityProviderResponseContext(
+      EntityProvider provider, 
+      Abdera abdera, 
+      String encoding) {
         super(abdera, encoding);
         this.provider = provider;
         init();
     }
 
-    public EntityProviderResponseContext(EntityProvider provider, Abdera abdera) {
+    public EntityProviderResponseContext(
+      EntityProvider provider, 
+      Abdera abdera) {
         super(abdera);
         this.provider = provider;
         init();



Mime
View raw message