abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1189362 [1/2] - in /abdera/abdera2: ./ activities/src/main/java/org/apache/abdera2/activities/model/ activities/src/main/java/org/apache/abdera2/activities/protocol/ activities/src/main/java/org/apache/abdera2/activities/protocol/basic/ co...
Date Wed, 26 Oct 2011 18:26:58 GMT
Author: jmsnell
Date: Wed Oct 26 18:26:55 2011
New Revision: 1189362

URL: http://svn.apache.org/viewvc?rev=1189362&view=rev
Log:
working on fixing up the test cases after the last big refactoring... more to come

Added:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicServiceManager.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparison.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Initializable.java   (with props)
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java   (contents, props changed)
      - copied, changed from r1187599, abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Functions.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/BasicActivitiesServiceManager.java   (with props)
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/CustomAtompubServiceManager.java   (with props)
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/basic/BasicAtompubServiceManager.java   (with props)
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomAtompubServiceManager.java   (with props)
Removed:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/AbstractItemManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/AbstractResolver.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Functions.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ItemManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/PoolManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Resolver.java
Modified:
    abdera/abdera2/.classpath
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ActivitiesServiceManager.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/AnnoUtil.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/Preference.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Chain.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractServiceManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionRequestProcessor.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Provider.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetFunctionResolver.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/AbstractAbderaServlet.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/ServletRequestContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaAsyncService.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaChannelServlet.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AbderaTask.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/AsyncAbderaServlet.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/DefaultProcessor.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/DefaultTaskExecutor.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/ProcessorQueue.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/servlet/async/TaskExecutor.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/ChannelManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/MapChannelManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/text/Codec.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/ActivitiesServlet.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/appserver/employee/AppServer.java
    abdera/abdera2/security/src/main/java/org/apache/abdera2/security/Security.java
    abdera/abdera2/security/src/main/java/org/apache/abdera2/security/xmlsec/XmlSignature.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/AtompubServiceManager.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubWorkspaceProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/DefaultAtompubProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/ServiceRequestProcessor.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/AsyncBasicTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/BasicTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/activities/server/TestChannelServlet.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/JettyServer.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/SecurityFilterTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/SimpleAdapter.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/JettyServer.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/basic/BasicTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomProviderTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java

Modified: abdera/abdera2/.classpath
URL: http://svn.apache.org/viewvc/abdera/abdera2/.classpath?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/.classpath (original)
+++ abdera/abdera2/.classpath Wed Oct 26 18:26:55 2011
@@ -1,25 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
-	<classpathentry kind="src" path="common/src/main/resources"/>
-	<classpathentry kind="src" path="examples/src/main/resources"/>
-	<classpathentry kind="src" path="examples/src/main/java"/>
-	<classpathentry kind="src" path="test/src/test/java"/>
-	<classpathentry kind="src" path="test/src/main/java"/>
-	<classpathentry kind="src" path="test/src/main/resources"/>
-	<classpathentry kind="src" path="server/src/main/resources"/>
-	<classpathentry kind="src" path="server/src/main/java"/>
-	<classpathentry kind="src" path="security/src/main/resources"/>
-	<classpathentry kind="src" path="security/src/main/java"/>
-	<classpathentry kind="src" path="ext/src/main/resources"/>
-	<classpathentry kind="src" path="ext/src/main/java"/>
-	<classpathentry kind="src" path="core/src/main/resources"/>
-	<classpathentry kind="src" path="core/src/main/java"/>
-	<classpathentry kind="src" path="common/src/main/java"/>
-	<classpathentry kind="src" path="client/src/main/java"/>
-	<classpathentry kind="src" path="client/src/main/resources"/>
-	<classpathentry kind="src" path="activities/src/main/resources"/>
-	<classpathentry kind="src" path="activities/src/main/java"/>
+	<classpathentry kind="src" output="common/target/classes" path="common/src/main/resources"/>
+	<classpathentry kind="src" output="examples/target/classes" path="examples/src/main/resources"/>
+	<classpathentry kind="src" output="examples/target/classes" path="examples/src/main/java"/>
+	<classpathentry kind="src" output="test/target/test-classes" path="test/src/test/java"/>
+	<classpathentry kind="src" output="test/target/classes" path="test/src/main/java"/>
+	<classpathentry kind="src" output="test/target/classes" path="test/src/main/resources"/>
+	<classpathentry kind="src" output="server/target/classes" path="server/src/main/resources"/>
+	<classpathentry kind="src" output="server/target/classes" path="server/src/main/java"/>
+	<classpathentry kind="src" output="security/target/classes" path="security/src/main/resources"/>
+	<classpathentry kind="src" output="security/target/classes" path="security/src/main/java"/>
+	<classpathentry kind="src" output="ext/target/classes" path="ext/src/main/resources"/>
+	<classpathentry kind="src" output="ext/target/classes" path="ext/src/main/java"/>
+	<classpathentry kind="src" output="core/target/classes" path="core/src/main/resources"/>
+	<classpathentry kind="src" output="core/target/classes" path="core/src/main/java"/>
+	<classpathentry kind="src" output="common/target/classes" path="common/src/main/java"/>
+	<classpathentry kind="src" output="client/target/classes" path="client/src/main/java"/>
+	<classpathentry kind="src" output="client/target/classes" path="client/src/main/resources"/>
+	<classpathentry kind="src" output="activities/target/classes" path="activities/src/main/resources"/>
+	<classpathentry kind="src" output="activities/target/classes" path="activities/src/main/java"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.5.0 (MacOS X Default)">
 		<attributes>
 			<attribute name="owner.project.facets" value="java"/>

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java Wed Oct 26 18:26:55 2011
@@ -132,8 +132,12 @@ public class Collection<T extends ASObje
   public static class CollectionGenerator<T extends ASObject> 
     extends ASObjectGenerator<Collection<T>> {
     
+    private static <T extends ASObject>Class<? extends Collection<T>> t(Class _class) {
+      return (Class<? extends Collection<T>>) _class;
+    }
+    
     public CollectionGenerator() {
-      super((Class<? extends Collection<T>>) Collection.class);
+      super(CollectionGenerator.<T>t(Collection.class));
     }
     
     public CollectionGenerator(Class<? extends Collection<T>> _class) {

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ActivitiesServiceManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ActivitiesServiceManager.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ActivitiesServiceManager.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ActivitiesServiceManager.java Wed Oct 26 18:26:55 2011
@@ -17,16 +17,14 @@
  */
 package org.apache.abdera2.activities.protocol;
 
+import static org.apache.abdera2.common.misc.MoreFunctions.*;
+
 import java.util.Map;
 
 import org.apache.abdera2.activities.model.IO;
 import org.apache.abdera2.activities.model.TypeAdapter;
-import org.apache.abdera2.common.Discover;
-import org.apache.abdera2.common.Localizer;
 import org.apache.abdera2.common.protocol.AbstractServiceManager;
 import org.apache.abdera2.common.protocol.Provider;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * The ServiceManager is used by the AbderaServlet to bootstrap the server 
@@ -34,9 +32,7 @@ import org.apache.commons.logging.LogFac
  * to use this class directly.
  */
 public class ActivitiesServiceManager
-  extends AbstractServiceManager<Provider> {
-
-    private final static Log log = LogFactory.getLog(ActivitiesServiceManager.class);
+  extends AbstractServiceManager {
 
     public ActivitiesServiceManager() {}
 
@@ -44,15 +40,13 @@ public class ActivitiesServiceManager
       return IO.get(adapters);
     }
     
-    public Provider newProvider(Map<String, String> properties) {
-        String instance = properties.get(PROVIDER);
-        if (instance == null)
-            instance = DefaultActivitiesProvider.class.getName();
-        log.debug(Localizer.sprintf("CREATING.NEW.INSTANCE", "Provider"));
-        Provider provider = Discover.locate(Provider.class, instance);
-        log.debug(Localizer.sprintf("INITIALIZING.INSTANCE", "Provider"));
-        provider.init(properties);
-        return provider;
+    @SuppressWarnings("unchecked")
+    public <P extends Provider>P newProvider(
+      Map<String, Object> properties) {
+        return (P)discoverInitializable(
+          Provider.class,
+          DefaultActivitiesProvider.class)
+            .apply(properties);
     }
     
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java Wed Oct 26 18:26:55 2011
@@ -21,7 +21,6 @@ import java.util.Collection;
 
 import javax.security.auth.Subject;
 
-import org.apache.abdera2.common.misc.Resolver;
 import org.apache.abdera2.common.protocol.DefaultWorkspaceManager;
 import org.apache.abdera2.common.protocol.Request;
 import org.apache.abdera2.common.protocol.RequestContext;
@@ -32,11 +31,13 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.WorkspaceInfo;
 import org.apache.abdera2.common.protocol.WorkspaceManager;
 
+import com.google.common.base.Function;
+
 public class DefaultActivitiesProvider
   extends AbstractActivitiesProvider {
 
-  protected Resolver<Target,RequestContext> targetResolver;
-  protected Resolver<Subject,Request> subjectResolver;
+  protected Function<RequestContext,Target> targetResolver;
+  protected Function<Request,Subject> subjectResolver;
   protected TargetBuilder<?> targetBuilder;
   protected RouteManager<TargetType,RequestContext> routeManager;
   
@@ -62,27 +63,27 @@ public class DefaultActivitiesProvider
       return routeManager;
   }
 
-  protected Resolver<Target,RequestContext> getTargetResolver(RequestContext request) {
+  protected Function<RequestContext,Target> getTargetResolver(RequestContext request) {
       return targetResolver;
   }
 
-  public void setTargetResolver(Resolver<Target,RequestContext> targetResolver) {
+  public void setTargetResolver(Function<RequestContext,Target> targetResolver) {
       this.targetResolver = targetResolver;
   }
 
-  protected Resolver<Subject,Request> getSubjectResolver(RequestContext request) {
+  protected Function<Request,Subject> getSubjectResolver(RequestContext request) {
       return subjectResolver;
   }
 
-  public void setSubjectResolver(Resolver<Subject,Request> subjectResolver) {
+  public void setSubjectResolver(Function<Request,Subject> subjectResolver) {
       this.subjectResolver = subjectResolver;
   }
 
-  public Resolver<Target,RequestContext> getTargetResolver() {
+  public Function<RequestContext,Target> getTargetResolver() {
       return targetResolver;
   }
 
-  public Resolver<Subject,Request> getSubjectResolver() {
+  public Function<Request,Subject> getSubjectResolver() {
       return subjectResolver;
   }
 

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicServiceManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicServiceManager.java?rev=1189362&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicServiceManager.java (added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicServiceManager.java Wed Oct 26 18:26:55 2011
@@ -0,0 +1,18 @@
+package org.apache.abdera2.activities.protocol.basic;
+
+import java.util.Map;
+
+import org.apache.abdera2.activities.protocol.ActivitiesServiceManager;
+import org.apache.abdera2.common.protocol.Provider;
+
+public class BasicServiceManager extends ActivitiesServiceManager {
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public <P extends Provider> P newProvider(Map<String, Object> properties) {
+    BasicProvider bp = new BasicProvider();
+    bp.init(properties);
+    return (P)bp;
+  }
+
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicServiceManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=1189362&r1=1189361&r2=1189362&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 Wed Oct 26 18:26:55 2011
@@ -23,7 +23,6 @@ import java.util.Set;
 
 import javax.xml.namespace.QName;
 
-
 public final class AnnoUtil {
 
   private AnnoUtil() {}

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=1189362&r1=1189361&r2=1189362&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 Wed Oct 26 18:26:55 2011
@@ -13,6 +13,7 @@ import org.joda.time.DateTimeZone;
 import org.joda.time.Duration;
 import org.joda.time.Interval;
 
+import static org.apache.abdera2.common.misc.Comparisons.*;
 import com.google.common.base.Equivalence;
 import com.google.common.base.Predicate;
 import com.google.common.base.Supplier;
@@ -66,7 +67,7 @@ public final class DateTimes {
     return dt.toDateTime(DateTimeZone.forID(id));
   }
   
-  public DateTimeBuilder makeDateTime() {
+  public static DateTimeBuilder makeDateTime() {
     return new DateTimeBuilder();
   }
   
@@ -74,6 +75,100 @@ public final class DateTimes {
     private int year, month, day, hour, minute, second, millis;
     private DateTimeZone dtz;
     public DateTimeBuilder() {}
+    private DateTime _now() {
+      return dtz == null ?
+        DateTimes.now() :
+        DateTimes.now(dtz);
+    }
+    public DateTimeBuilder thisYear() {
+      this.year = _now().year().get();
+      return this;
+    }
+    public DateTimeBuilder thisMonth() {
+      this.month = _now().monthOfYear().get();
+      return this;
+    }
+    public DateTimeBuilder thisDay() {
+      this.day = _now().dayOfMonth().get();
+      return this;
+    }
+    public DateTimeBuilder thisHour() {
+      this.hour = _now().hourOfDay().get();
+      return this;
+    }
+    public DateTimeBuilder thisMinute() {
+      this.minute = _now().minuteOfHour().get();
+      return this;
+    }
+    public DateTimeBuilder thisSecond() {
+      this.second = _now().secondOfMinute().get();
+      return this;
+    }
+    public DateTimeBuilder thisMillisecond() {
+      this.millis = _now().millisOfSecond().get();
+      return this;
+    }
+    public DateTimeBuilder thisTimeZone() {
+      this.dtz = _now().getZone();
+      return this;
+    }
+    public DateTimeBuilder thisDate() {
+      DateTime now = _now();
+      this.year = now.year().get();
+      this.month = now.monthOfYear().get();
+      this.day = now.dayOfMonth().get();
+      return this;
+    }
+    public DateTimeBuilder thisDatePlusYears(int years) {
+      thisDate();
+      this.year += years;
+      return this;
+    }
+    public DateTimeBuilder thisDatePlusMonths(int months) {
+      thisDate();
+      this.year += months / 12;
+      this.month += months % 12;
+      return this;
+    }
+    public DateTimeBuilder thisDatePlusDays(int days) {
+      thisDate();
+      this.year += days / 365;
+      int rem = days % 365;
+      this.month += rem / 31;
+      this.day += rem % 31;
+      return this;
+    }
+    public DateTimeBuilder thisTime() {
+      DateTime now = _now();
+      this.hour = now.hourOfDay().get();
+      this.minute = now.minuteOfHour().get();
+      this.second = now.secondOfMinute().get();
+      this.millis = now.millisOfSecond().get();
+      return this;
+    }
+    public DateTimeBuilder nowUtc() {
+      timezoneUTC();
+      DateTime now = _now();
+      this.year = now.year().get();
+      this.month = now.monthOfYear().get();
+      this.day = now.dayOfMonth().get();
+      this.hour = now.hourOfDay().get();
+      this.minute = now.minuteOfHour().get();
+      this.second = now.secondOfMinute().get();
+      this.millis = now.millisOfSecond().get();
+      return this;
+    }
+    public DateTimeBuilder now() {
+      DateTime now = _now();
+      this.year = now.year().get();
+      this.month = now.monthOfYear().get();
+      this.day = now.dayOfMonth().get();
+      this.hour = now.hourOfDay().get();
+      this.minute = now.minuteOfHour().get();
+      this.second = now.secondOfMinute().get();
+      this.millis = now.millisOfSecond().get();
+      return this;
+    }
     public DateTimeBuilder year(int year) {
       this.year = year;
       return this;
@@ -106,6 +201,10 @@ public final class DateTimes {
       this.dtz = DateTimeZone.forTimeZone(tz);
       return this;
     }
+    public DateTimeBuilder timezoneUTC() {
+      this.dtz = DateTimeZone.UTC;
+      return this;
+    }
     public DateTimeBuilder timezone(String id) {
       this.dtz = DateTimeZone.forID(id);
       return this;
@@ -119,15 +218,23 @@ public final class DateTimes {
       return this;
     }
     public DateTime get() {
-      return new DateTime(year,month,day,hour,minute,second,millis,dtz);
+      return new DateTime(
+        year,
+        Math.min(12,Math.max(1,month)),
+        Math.min(31,Math.max(1,day)),
+        hour,
+        minute,
+        second,
+        millis,
+        dtz);
     }
   }
   
   public static abstract class DateTimeComparator<X> implements Comparator<X> {
     public int innerCompare(DateTime d1, DateTime d2) {
-      if (d1 != null && d2 == null) return 1;
-      if (d1 == null && d2 != null) return -1;
-      if (d1 == null && d2 == null) return 0;
+      if (onlySecondIsNull(d1,d2)) return 1;
+      if (onlyFirstIsNull(d1,d2)) return -1;
+      if (bothAreNull(d1,d2)) return 0;
       return d1.compareTo(d2);
     }
   }
@@ -156,6 +263,10 @@ public final class DateTimes {
     return DateTime.now(DateTimeZone.forID(tz));
   }
   
+  public static DateTime now(DateTimeZone dtz) {
+    return DateTime.now(dtz);
+  }
+  
   public static DateTime now(TimeZone tz) {
     return DateTime.now(DateTimeZone.forTimeZone(tz));
   }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Preference.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Preference.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Preference.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Preference.java Wed Oct 26 18:26:55 2011
@@ -30,6 +30,7 @@ public class Preference implements Seria
   public static final String RETURN_ACCEPTED = "return-accepted";
   public static final String RETURN_CONTENT = "return-content";
   public static final String RETURN_STATUS = "return-status";
+  public static final String WAIT = "wait";
   
   /** 
    * The "return-no-content" token indicates that the client prefers that
@@ -57,6 +58,14 @@ public class Preference implements Seria
   public static final Preference PREF_RETURN_CONTENT =
     new Preference(RETURN_CONTENT);
   
+  public static Preference WAIT(long millis) {
+    return 
+      make()
+        .token(WAIT)
+        .value(millis)
+     .get();
+  }
+  
   public static Builder make() {
     return new Builder();
   }
@@ -82,6 +91,26 @@ public class Preference implements Seria
       return this;
     }
     
+    public Builder value(long value) {
+      this.value = Long.toString(value);
+      return this;
+    }
+    
+    public Builder value(int value) {
+      this.value = Integer.toString(value);
+      return this;
+    }
+    
+    public Builder value(short value) {
+      this.value = Short.toString(value);
+      return this;
+    }
+    
+    public Builder value(boolean value) {
+      this.value = Boolean.toString(value);
+      return this;
+    }
+    
     public Builder param(String key, String val) {
       if (key == null || reserved(key)) 
         throw new IllegalArgumentException();
@@ -134,6 +163,22 @@ public class Preference implements Seria
     return value;
   }
   
+  public long getLongValue() {
+    return Long.parseLong(value);
+  }
+  
+  public int getIntValue() {
+    return Integer.parseInt(value);
+  }
+  
+  public short getShortValue() {
+    return Short.parseShort(value);
+  }
+  
+  public boolean getBooleanValue() {
+    return Boolean.parseBoolean(value);
+  }
+  
   private static final Set<String> reserved = 
     new HashSet<String>();
   static {
@@ -314,4 +359,11 @@ public class Preference implements Seria
         ((Collection<Preference>)preferences).contains(preference) :
         contains(preferences,preference.getToken());
   }
+  
+  public static Preference get(Iterable<Preference> preferences, String token) {
+    for (Preference pref : preferences)
+      if (pref.matches(token))
+        return pref;
+    return 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=1189362&r1=1189361&r2=1189362&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 Wed Oct 26 18:26:55 2011
@@ -17,7 +17,6 @@ package org.apache.abdera2.common.misc;
  * directory of this distribution.
  */
 
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -28,10 +27,12 @@ import com.google.common.base.Supplier;
 
 import static com.google.common.base.Preconditions.*;
 
-public final class Chain<T,R> implements Function<T,R> {
+public final class Chain<T,R> 
+  implements Function<T,R> {
 
     private final Iterator<Task<T,R>> tasks;
     private final Function<T,R> to;
+    private boolean started = false;
 
     public Chain(Function<T,R> to, Task<T,R>... tasks) {
       this.to = to;
@@ -50,9 +51,12 @@ public final class Chain<T,R> implements
     }
 
     public R apply(T input) {
+      checkState(!started,"Chain has already been started");
+      started = true;
       return next(input);
     }
 
+    @SuppressWarnings("synthetic-access")
     public static <T,R>Builder<T,R> make() {
       return new Builder<T,R>();
     }
@@ -75,6 +79,12 @@ public final class Chain<T,R> implements
           via(task);
         return this;
       }
+      /**
+       * Creates a Task that applies specified functions to the input and output.
+       */
+      public Builder<T,R> via(Function<T,T> in, Function<R,R> out) {
+        return via(new FunctionTask<T,R>(in,out));
+      }
       public Builder<T,R> via(Iterable<? extends Task<T,R>> tasks) {
         for (Task<T,R> task : tasks)
           via(task);
@@ -89,4 +99,21 @@ public final class Chain<T,R> implements
         return new Chain<T,R>(finalTask,tasks);
       }
     }
+    
+    private static class FunctionTask<T,R> 
+      implements Task<T, R> {
+      private final Function<T,T> in;
+      private final Function<R,R> out;
+      FunctionTask(
+        Function<T,T> in, 
+        Function<R,R> out) {
+        this.in = in;
+        this.out = out;
+      }
+      public R apply(T input, Chain<T, R> flow) {
+        input = in != null ? in.apply(input) : input;
+        R output = flow.next(input);
+        return out != null ? out.apply(output) : output;
+      }
+    }
 }

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparison.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparison.java?rev=1189362&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparison.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparison.java Wed Oct 26 18:26:55 2011
@@ -0,0 +1,58 @@
+package org.apache.abdera2.common.misc;
+
+/**
+ * A Comparison is similiar to Comparable in that it compares
+ * the equivalence of two Objects based on some specific condition,
+ * however, unlike Comparable which returns either a -1, 0 or 1 
+ * for use when Sorting objects, Comparison returns a simple boolean
+ * response similar to a Predicate.
+ * 
+ * A Comparison is similar to the Guava Libraries Equivalence but 
+ * differs semantically.. the purpose of an Equivalence is to test
+ * whether two items are semantically equivalent to one another, either
+ * in terms of equality, identity, or identical meaning. A 
+ * Comparison, on the other hand, checks only to see if the two objects
+ * adhere to some arbitrary comparison logic regardless of whether the
+ * two objects are semantically equivalent.
+ */
+public abstract class Comparison<R> {
+
+  public abstract boolean apply(R r1, R r2);
+  
+  public Comparison<R> negate() {
+    final Comparison<R> _this = this;
+    return new Comparison<R>() {
+      public boolean apply(R r1, R r2) {
+        return !_this.apply(r1, r2);
+      }
+    };
+  }
+  
+  public Comparison<R> and(final Comparison<R> other) {
+    final Comparison<R> _this = this;
+    return new Comparison<R>() {
+      public boolean apply(R r1, R r2) {
+        return _this.apply(r1, r2) && other.apply(r1, r2);
+      }      
+    };
+  }
+  
+  public Comparison<R> or(final Comparison<R> other) {
+    final Comparison<R> _this = this;
+    return new Comparison<R>() {
+      public boolean apply(R r1, R r2) {
+        return _this.apply(r1, r2) || other.apply(r1, r2);
+      }
+    };
+  }
+  
+  public Comparison<R> not(final Comparison<R> other) {
+    final Comparison<R> _this = this;
+    return new Comparison<R>() {
+      public boolean apply(R r1, R r2) {
+        return _this.apply(r1, r2) && !other.apply(r1, r2);
+      }
+    };
+  } 
+
+}

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

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java?rev=1189362&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Comparisons.java Wed Oct 26 18:26:55 2011
@@ -0,0 +1,226 @@
+package org.apache.abdera2.common.misc;
+
+import com.google.common.base.Equivalence;
+import com.google.common.base.Predicate;
+import static com.google.common.base.Preconditions.*;
+
+public class Comparisons {
+
+  private Comparisons() {}
+  
+  public static <R>Comparison<R> forEquivalence(final Equivalence<R> r) {
+    return new Comparison<R>() {
+      public boolean apply(R r1, R r2) {
+        return r.equivalent(r1, r2);
+      }
+    };
+  }
+  
+  public static <T>Comparison<T> and(final Comparison<T>...comparisons) {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        for (Comparison<T> compare : comparisons)
+          if (!compare.apply(r1, r2))
+            return false;
+        return true;
+      }      
+    };
+  }
+  
+  public static <T>Comparison<T> or(final Comparison<T>...comparisons) {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        for (Comparison<T> compare : comparisons)
+          if (compare.apply(r1, r2))
+            return true;
+        return false;
+      }      
+    };
+  }
+  
+  public static <T>boolean bothAreNull(T t1, T t2) {
+    return bothAreNull().apply(t1,t2);
+  }
+  
+  public static <T>boolean onlyFirstIsNull(T t1, T t2) {
+    return onlyFirstIsNull().apply(t1,t2);
+  }
+  
+  public static <T>boolean onlySecondIsNull(T t1, T t2) {
+    return onlySecondIsNull().apply(t1,t2);
+  }
+  
+  public static <T>boolean onlyOneIsNull(T t1, T t2) {
+    return onlyOneIsNull().apply(t1,t2);
+  }
+  
+  public static <T>boolean neitherIsNull(T t1, T t2) {
+    return neitherIsNull().apply(t1,t2);
+  }
+  
+  public static <T>boolean bothApply(T t1, T t2, Predicate<T> predicate) {
+    return bothApply(predicate).apply(t1,t2);
+  }
+  
+  public static <T>boolean neitherApply(T t1, T t2, Predicate<T> predicate) {
+    return neitherApply(predicate).apply(t1,t2);
+  }
+  
+  public static <T>boolean eitherApply(T t1, T t2, Predicate<T> predicate) {
+    return eitherApply(predicate).apply(t1, t2);
+  }
+  
+  public static <T>boolean onlyFirstApplies(T t1, T t2, Predicate<T> predicate) {
+    return onlyFirstApplies(predicate).apply(t1, t2);
+  }
+
+  public static <T>boolean onlySecondApplies(T t1, T t2, Predicate<T> predicate) {
+    return onlySecondApplies(predicate).apply(t1, t2);
+  }
+  
+  public static final Comparison<Object> bothAreNull = 
+    bothAreNull();
+  
+  public static final Comparison<Object> onlyFirstIsNull = 
+    onlyFirstIsNull();
+  
+  public static final Comparison<Object> onlySecondIsNull = 
+    onlySecondIsNull();
+  
+  public static final Comparison<Object> onlyOneIsNull = 
+    onlyOneIsNull();
+  
+  public static final Comparison<Object> neitherIsNull = 
+    neitherIsNull();
+  
+  @SuppressWarnings("unchecked")
+  public static <X extends Predicate<? extends T[]>,T>X asPredicate(
+    final Comparison<T> comparison) {
+    return (X)new Predicate<T[]>() {
+      public boolean apply(T[] input) {
+        checkNotNull(input);
+        checkArgument(
+          input.length == 2, 
+          "The input array must have exactly two items");
+        return comparison.apply(input[0],input[1]);
+      }
+    };
+  }
+  
+  public static <X extends Predicate<? extends T[]>,T>X asPredicate(
+    final Equivalence<T> equivalence) {
+      return Comparisons.<X,T>asPredicate(forEquivalence(equivalence));
+  }
+  
+  /**
+   * Returns a Comparison that checks both inputs against a Predicate
+   */
+  public static <T>Comparison<T> bothApply(final Predicate<T> predicate) {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return predicate.apply(r1) && predicate.apply(r2);
+      }
+    };
+  }
+  
+  /**
+   * Returns a Comparison that checks both inputs against a Predicate
+   */
+  public static <T>Comparison<T> onlyFirstApplies(final Predicate<T> predicate) {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return predicate.apply(r1) && !predicate.apply(r2);
+      }
+    };
+  }
+  
+  /**
+   * Returns a Comparison that checks both inputs against a Predicate
+   */
+  public static <T>Comparison<T> eitherApply(final Predicate<T> predicate) {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return predicate.apply(r1) || predicate.apply(r2);
+      }
+    };
+  }
+  
+  /**
+   * Returns a Comparison that checks both inputs against a Predicate
+   */
+  public static <T>Comparison<T> onlySecondApplies(final Predicate<T> predicate) {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return !predicate.apply(r1) && predicate.apply(r2);
+      }
+    };
+  }
+  
+  /**
+   * Returns a Comparison that checks both inputs against a Predicate
+   */
+  public static <T>Comparison<T> neitherApply(final Predicate<T> predicate) {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return !predicate.apply(r1) && !predicate.apply(r2);
+      }
+    };
+  }
+  
+  /**
+   * Returns true if both input objects are null
+   */
+  public static <T>Comparison<T> bothAreNull() {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return r1 == null && r2 == null;
+      }      
+    };
+  }
+
+  /**
+   * Returns true if only the first of the two input objects is null;
+   */
+  public static <T>Comparison<T> onlyFirstIsNull() {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return r1 == null && r2 != null;
+      }
+    };
+  }
+  
+  /**
+   * Returns true if only the second of the two input objects is null;
+   */
+  public static <T>Comparison<T> onlySecondIsNull() {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return r1 != null && r2 == null;
+      }
+    };
+  }
+  
+  /**
+   * Returns true if only one of the two input objects is null;
+   */
+  public static <T>Comparison<T> onlyOneIsNull() {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return (r1 == null && r2 != null) ||
+               (r1 != null && r2 == null);
+      }
+    };
+  }
+  
+  /**
+   * Returns true if neither input objects are null
+   */
+  public static <T>Comparison<T> neitherIsNull() {
+    return new Comparison<T>() {
+      public boolean apply(T r1, T r2) {
+        return r1 != null && r2 != null;
+      }      
+    };
+  }
+  
+}

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

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Initializable.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Initializable.java?rev=1189362&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Initializable.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Initializable.java Wed Oct 26 18:26:55 2011
@@ -0,0 +1,9 @@
+package org.apache.abdera2.common.misc;
+
+import java.util.Map;
+
+public interface Initializable {
+
+  void init(Map<String,Object> properties);
+  
+}

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

Copied: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java (from r1187599, abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Functions.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java?p2=abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java&p1=abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Functions.java&r1=1187599&r2=1189362&rev=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/Functions.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java Wed Oct 26 18:26:55 2011
@@ -2,14 +2,196 @@ package org.apache.abdera2.common.misc;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.abdera2.common.Discover;
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
 import com.google.common.collect.Iterables;
 
-public class Functions {
+public class MoreFunctions {
+ 
+  public static <R extends Initializable>Function<Map<String,Object>,R> discoverInitializable(
+    final Class<R> _class) {
+      return discoverInitializable(_class,null);
+  }
+  
+  public static <R extends Initializable>Function<Map<String,Object>,R> discoverInitializable(
+    final Class<R> _class, 
+    final Class<? extends R> _instance) {
+    return new Function<Map<String,Object>,R>() {
+      public R apply(Map<String, Object> input) {
+        if (input == null) return null;
+        String instance = (String)input.get(_class.getName());
+        if (instance == null && _instance != null)
+          instance = _instance.getName();
+        R r = (R)Discover.locate(_class, instance);
+        r.init(input);
+        return r;
+      }
+    };
+  }
+  
+  public static <T>T firstNonNull(T... items) {
+    return MoreFunctions.<T>firstNonNullArray().apply(items);
+  }
+  
+  public static <T>T firstNonNull(Iterable<T> items) {
+    return MoreFunctions.<T>firstNonNull().apply(items);
+  }
+  
+  /**
+   * Returns a Function that returns the first non-null input
+   */
+  public static <T>Function<Iterable<T>,T> firstNonNull() {
+    return new Function<Iterable<T>,T>() {
+      public T apply(Iterable<T> input) {
+        for (T t : input)
+          if (t != null) return t;
+        return null;
+      }
+    };
+  }
+  
+  /**
+   * Returns a Function that returns the first non-null input
+   */
+  public static <T>Function<T[],T> firstNonNullArray() {
+    return new Function<T[],T>() {
+      public T apply(T[] input) {
+        for (T t : input)
+          if (t != null) return t;
+        return null;
+      }
+    };
+  }
   
+  /**
+   * Used to build an immutable, thread-safe Function<T,R> wrapping one or more 
+   * Predicate<T>'s associated with exactly one Supplier<R>. The input T is 
+   * tested against each Predicate<T> in the order defined and returns the 
+   * value of the Supplier<R> if Predicate.apply() returns true. A default 
+   * return value can be optionally specified, otherwise if no predicates 
+   * apply, the function returns null.
+   */
+  public static <T,R>ChoiceGenerator<T, R> choice() {
+    return new ChoiceGenerator<T,R>();
+  }
+  
+  /**
+   * Creates an option for use with a Choice Function
+   */
+  public static <T,R>Choice.Option<T,R> option(
+    final Predicate<T> predicate, 
+    final Supplier<R> supplier) {
+    return new Choice.Option<T,R>() {
+      public boolean apply(T input) {
+        return predicate.apply(input);
+      }
+      public R get() {
+        return supplier.get();
+      }        
+    };
+  }
+  
+  /**
+   * Creates an option for use with a Choice Function
+   */
+  public static <T,R>Choice.Option<T,R> option(
+    final Predicate<T> predicate,
+    final R object) {
+      return MoreFunctions.<T,R>option(
+        predicate, 
+        Suppliers.ofInstance(object));
+  }
+  
+  /**
+   * Creates a Function that applies a Predicate to a list of inputs and 
+   * returns the first matching item or null
+   */
+  public static <T>Function<Iterable<T>,T> oneOf(final Predicate<T> predicate) {
+    return oneOf(predicate,null);
+  }
+  
+  /**
+   * Creates a Function that applies a Predicate to a list of inputs and 
+   * returns the first matching item or the specified default value
+   */
+  public static <T>Function<Iterable<T>,T> oneOf(final Predicate<T> predicate, final T def) {
+    return new Function<Iterable<T>,T>() {
+      public T apply(Iterable<T> input) {
+        try {
+          return Iterables.<T>find(input, predicate);
+        } catch (Throwable t) {
+          return def;
+        }
+      }
+    };
+  }
+  
+  /**
+   * Creates a Function that applies a Predicate to a list of inputs and 
+   * returns the first matching item or null
+   */
+  public static <T>Function<T[],T> oneOfArray(final Predicate<T> predicate) {
+    return oneOfArray(predicate,null);
+  }
+  
+  /**
+   * Creates a Function that applies a Predicate to a list of inputs and 
+   * returns the first matching item or the specified default value
+   */
+  public static <T>Function<T[],T> oneOfArray(final Predicate<T> predicate, final T def) {
+    return new Function<T[],T>() {
+      public T apply(T[] input) {
+        try {
+          return Iterables.<T>find(Arrays.asList(input), predicate);
+        } catch (Throwable t) {
+          return def;
+        }
+      }
+    };
+  }
+  
+  /**
+   * Returns a function that takes an array of input T and applies a 
+   * function to each member to produce an array of output X.
+   */
+  public static <T,X>Function<T[],X[]> eachArray(
+    final Function<T,X> apply, final Class<X> _class) {
+      return new Function<T[],X[]>() {
+        public X[] apply(T[] input) {
+          return each(input, apply, _class);
+        }
+      };
+  }
+    
+  /**
+   * Returns a function that takes an array of input T and applies a 
+   * function to each member for which the Predicate<T> evaluates true
+   * to produce an array of output X.
+   */
+  public static <T,X>Function<T[],X[]> eachArray(
+    final Function<T,X> apply, 
+    final Predicate<T> predicate,
+    final Class<X> _class) {
+      return new Function<T[],X[]>() {
+        public X[] apply(T[] input) {
+          return each(input, apply, predicate, _class);
+        }
+      };
+  }
+  
+  /**
+   * Returns a function that takes an Iterable of input T and applies a 
+   * function to each member to produce an Iterable of output X.
+   */
   public static <T,X>Function<Iterable<T>,Iterable<X>> each(
     final Function<T,X> apply) {
       return new Function<Iterable<T>,Iterable<X>>() {
@@ -19,6 +201,11 @@ public class Functions {
       };
   }
   
+  /**
+   * Returns a function that takes an Iterable of input T and applies a 
+   * function to each member for which the Predicate<T> evaluates true
+   * to produce an Iterable of output X.
+   */
   public static <T,X>Function<Iterable<T>,Iterable<X>> each(
     final Function<T,X> apply,
     final Predicate<T> predicate) {
@@ -55,12 +242,62 @@ public class Functions {
   }
   
   public static <T,X>X[] each(T[] i, Function<T,X> apply, Class<X> _class) {
-    Iterable<X> x = Functions.<T,X>each(Arrays.<T>asList(i),apply);
+    Iterable<X> x = MoreFunctions.<T,X>each(Arrays.<T>asList(i),apply);
     return Iterables.<X>toArray(x, _class);
   }
   
   public static <T,X>X[] each(T[] i, Function<T,X> apply,Predicate<T> pred, Class<X> _class) {
-    Iterable<X> x = Functions.<T,X>each(Arrays.<T>asList(i),apply,pred);
+    Iterable<X> x = MoreFunctions.<T,X>each(Arrays.<T>asList(i),apply,pred);
     return Iterables.<X>toArray(x, _class);
   }
+  
+  public static <T>T[] array(T...t){
+    return t;
+  }
+  
+  public static class ChoiceGenerator<T,R> implements Supplier<Function<T,R>> {
+    private final Set<Choice.Option<T,R>> options = 
+      new LinkedHashSet<Choice.Option<T,R>>();
+    private Supplier<R> otherwise;
+    public ChoiceGenerator<T,R> of(Choice.Option<T,R> option) {
+      this.options.add(option);
+      return this;
+    }
+    public ChoiceGenerator<T,R> of(Predicate<T> predicate, Supplier<R> supplier) {
+      return of(option(predicate, supplier));
+    }
+    public ChoiceGenerator<T,R> of(Predicate<T> predicate, R instance) {
+      return of(option(predicate, instance));
+    }
+    public ChoiceGenerator<T,R> otherwise(Supplier<R> supplier) {
+      this.otherwise = supplier;
+      return this;
+    }
+    public ChoiceGenerator<T,R> otherwise(R instance) {
+      return otherwise(Suppliers.ofInstance(instance));
+    }
+    public Function<T,R> get() {
+      return new Choice<T,R>(options,otherwise);
+    }
+  }
+  
+  private static class Choice<T,R> implements Function<T,R> {    
+    public static interface Option<T,R>
+    extends Predicate<T>, Supplier<R> {}
+    private final Set<Choice.Option<T,R>> options = 
+      new LinkedHashSet<Choice.Option<T,R>>();
+    private final Supplier<R> otherwise;
+    private Choice(Set<Choice.Option<T,R>> options, Supplier<R> otherwise) {
+      this.options.addAll(options);
+      this.otherwise = otherwise;
+    }
+    public R apply(T input) {
+      for (Choice.Option<T,R> option : options) {
+        if (option.apply(input))
+          return option.get();
+      }
+      return otherwise != null ? otherwise.get() : null;
+    }
+  }
+  
 }

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

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractBaseRequestContext.java Wed Oct 26 18:26:55 2011
@@ -34,38 +34,32 @@ public abstract class AbstractBaseReques
     protected final String method;
     protected final IRI requestUri;
     protected final IRI baseUri;
+    protected final Principal principal;
     protected Subject subject;
-    protected Principal principal;
     protected Target target;
     
     protected AbstractBaseRequestContext(
-        Provider provider, 
-        String method, 
-        IRI requestUri, 
-        IRI baseUri) {
+      Provider provider, 
+      String method, 
+      IRI requestUri, 
+      IRI baseUri,
+      Principal principal) {
         this.provider = provider;
         this.method = method;
         this.baseUri = baseUri;
         this.requestUri = requestUri;
+        this.principal = principal;
     }
     
-    protected Target initTarget(Provider provider) {
+    protected Target initTarget() {
       try {
-          return provider.resolveTarget(this);
+        Target target = provider.resolveTarget(this);
+        return target != null ? 
+          target : 
+          new SimpleTarget(TargetType.TYPE_NOT_FOUND, this);
       } catch (Exception e) {
           throw new RuntimeException(e);
       }
-  }
-    
-    protected Target initTarget() {
-        try {
-            Target target = initTarget(provider);
-            return target != null ? 
-              target : 
-              new SimpleTarget(TargetType.TYPE_NOT_FOUND, this);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
     }
 
     public IRI getBaseUri() {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java Wed Oct 26 18:26:55 2011
@@ -35,9 +35,6 @@ import org.apache.abdera2.common.text.Ur
  */
 public abstract class AbstractMessage implements Message {
 
-    protected int flags = 0;
-    protected long max_age = -1;
-
     public CacheControl getCacheControl() {
         String cc = getHeader("Cache-Control");
         return cc != null ? CacheControl.parse(cc) : null;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java Wed Oct 26 18:26:55 2011
@@ -36,8 +36,9 @@ import org.apache.abdera2.common.http.Ca
 import org.apache.abdera2.common.http.EntityTag;
 import org.apache.abdera2.common.http.Preference;
 import org.apache.abdera2.common.http.WebLink;
+import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.mediatype.MimeTypeHelper;
-import org.apache.abdera2.common.misc.Functions;
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.joda.time.DateTime;
 
 import com.google.common.collect.Iterables;
@@ -81,7 +82,7 @@ public abstract class AbstractResponseCo
 
     public <T extends ResponseContext>T setEncodedHeader(String name, String charset, String... vals) {
         String[] evals = 
-          Functions.<String,String>each(
+          MoreFunctions.<String,String>each(
             vals, Codec.encodeStar(charset), String.class);
         return (T)setHeader(name, (Object[])evals);
     }
@@ -107,7 +108,7 @@ public abstract class AbstractResponseCo
     }
 
     public <T extends ResponseContext>T addEncodedHeaders(String name, String charset, String... vals) {
-      String[] evals = Functions.<String,String>each(vals, Codec.encodeStar(charset),String.class);
+      String[] evals = MoreFunctions.<String,String>each(vals, Codec.encodeStar(charset),String.class);
       addHeaders(name,(Object[])evals);
       return (T)this;
     }
@@ -150,10 +151,15 @@ public abstract class AbstractResponseCo
         return null;
     }
 
+    private Object getFirst(Iterable<Object> i, Object def) {
+      if (i == null) return def;
+      return Iterables.getFirst(i, def);
+    }
+    
     public String getHeader(String name) {
       Map<String, Iterable<Object>> headers = getHeaders();
       Iterable<Object> values = headers.get(name);
-      Object obj = Iterables.getFirst(values,null);
+      Object obj = getFirst(values,null);
       return obj != null ? obj.toString() : null;
     }
 
@@ -227,6 +233,9 @@ public abstract class AbstractResponseCo
     public <T extends ResponseContext>T setLocation(String uri) {
         return (T)(uri == null ? removeHeader("Location") : setHeader("Location", uri));
     }
+    public <T extends ResponseContext>T setLocation(IRI iri) {
+      return setLocation(iri == null ? null : iri.toString());
+    }
 
     public int getStatus() {
         return status;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractServiceManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractServiceManager.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractServiceManager.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractServiceManager.java Wed Oct 26 18:26:55 2011
@@ -19,54 +19,46 @@ package org.apache.abdera2.common.protoc
 
 import java.util.Map;
 
-import org.apache.abdera2.common.Discover;
-import org.apache.abdera2.common.Localizer;
 import org.apache.abdera2.common.protocol.servlet.async.DefaultProcessor;
 import org.apache.abdera2.common.protocol.servlet.async.DefaultTaskExecutor;
 import org.apache.abdera2.common.protocol.servlet.async.ProcessorQueue;
 import org.apache.abdera2.common.protocol.servlet.async.TaskExecutor;
 import org.apache.abdera2.common.pusher.ChannelManager;
 import org.apache.abdera2.common.pusher.SimpleChannelManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import static org.apache.abdera2.common.misc.MoreFunctions.*;
 
 /**
- * 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. There should be little to no reason why an end user would 
+ * need to use this class directly.
  */
-public abstract class AbstractServiceManager<P extends Provider> 
-  implements ServiceManager<P> {
-
-    private final static Log log = LogFactory.getLog(AbstractServiceManager.class);
+public abstract class AbstractServiceManager 
+  implements ServiceManager {
 
     protected AbstractServiceManager() {}
 
-    public ProcessorQueue newProcessorQueue(Map<String, String> properties) {
-      String instance = properties.get(PROCESSORQUEUE);
-      if (instance == null)
-        instance = DefaultProcessor.class.getName();
-      log.debug(Localizer.sprintf("CREATING.NEW.INSTANCE", "ProcessorQueue"));
-      ProcessorQueue queue = (ProcessorQueue)Discover.locate(ProcessorQueue.class, instance);
-      return queue;
+    public ProcessorQueue newProcessorQueue(
+      Map<String, Object> properties) {    
+        return discoverInitializable(
+          ProcessorQueue.class,
+          DefaultProcessor.class)
+            .apply(properties);
     }
     
-    public TaskExecutor newTaskExecutor(Map<String, String> properties) {
-      String instance = properties.get(TASKEXECUTOR);
-      if (instance == null)
-        instance = DefaultTaskExecutor.class.getName();
-      log.debug(Localizer.sprintf("CREATING.NEW.INSTANCE", "TaskExecutor"));
-      TaskExecutor exec = (TaskExecutor)Discover.locate(TaskExecutor.class, instance);
-      exec.init(properties);
-      return exec;
+    public TaskExecutor newTaskExecutor(
+      Map<String, Object> properties) {  
+        return discoverInitializable(
+            TaskExecutor.class,
+            DefaultTaskExecutor.class)
+              .apply(properties);
     }
     
-    public ChannelManager newChannelManager(Map<String, String> properties) {
-      String instance = properties.get(CHANNELMANAGER);
-      if (instance == null)
-        instance = SimpleChannelManager.class.getName();
-      log.debug(Localizer.sprintf("CREATING.NEW.INSTANCE", "ChannelManager"));
-      ChannelManager cm = (ChannelManager)Discover.locate(ChannelManager.class, instance);
-      cm.init(properties);
-      return cm;
+    public ChannelManager newChannelManager(
+      Map<String, Object> properties) {
+        return discoverInitializable(
+            ChannelManager.class,
+            SimpleChannelManager.class)
+              .apply(properties);
     }
+    
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java Wed Oct 26 18:26:55 2011
@@ -23,9 +23,10 @@ import java.util.Set;
 
 import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.common.http.EntityTag;
-import org.apache.abdera2.common.misc.Resolver;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Function;
+
 /**
  * An abstract base Provider implementation that implements the WorkspaceManager interface. This is intended to be used
  * by Provider's that do not wish to use a separate WorkspaceManager object.
@@ -34,7 +35,7 @@ public abstract class AbstractWorkspaceP
     extends BaseProvider 
       implements WorkspaceManager {
 
-    protected Resolver<Target,RequestContext> targetResolver;
+    protected Function<RequestContext,Target> targetResolver;
     protected TargetBuilder<?> targetBuilder;
     protected final Set<WorkspaceInfo> workspaces = 
       new LinkedHashSet<WorkspaceInfo>();
@@ -43,7 +44,7 @@ public abstract class AbstractWorkspaceP
       return this;
     }
 
-    protected Resolver<Target,RequestContext> getTargetResolver(RequestContext request) {
+    protected Function<RequestContext,Target> getTargetResolver(RequestContext request) {
         return targetResolver;
     }
 
@@ -56,7 +57,7 @@ public abstract class AbstractWorkspaceP
         this.targetBuilder = targetBuilder;
     }
 
-    protected void setTargetResolver(Resolver<Target,RequestContext> targetResolver) {
+    protected void setTargetResolver(Function<RequestContext,Target> targetResolver) {
         this.targetResolver = targetResolver;
     }
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java Wed Oct 26 18:26:55 2011
@@ -27,7 +27,6 @@ import java.util.Set;
 import javax.security.auth.Subject;
 
 import org.apache.abdera2.common.misc.Chain;
-import org.apache.abdera2.common.misc.Resolver;
 import org.apache.abdera2.common.misc.Task;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -43,18 +42,18 @@ public abstract class BaseProvider
   implements Provider {
 
     private final static Log log = LogFactory.getLog(BaseProvider.class);
-    protected Map<String, String> properties;
+    protected Map<String, Object> properties;
     protected Set<Task<RequestContext,ResponseContext>> filters = 
       new LinkedHashSet<Task<RequestContext,ResponseContext>>();
     protected Map<TargetType, Function<CollectionAdapter,? extends RequestProcessor>> requestProcessors = 
       new HashMap<TargetType, Function<CollectionAdapter,? extends RequestProcessor>>();
 
-    public void init(Map<String,String> properties) {
-      this.properties = properties != null ? properties : new HashMap<String,String>();
+    public void init(Map<String,Object> properties) {
+      this.properties = properties != null ? properties : new HashMap<String,Object>();
     }
 
     public String getProperty(String name) {
-        return properties.get(name);
+        return (String)properties.get(name);
     }
 
     public Iterable<String> getPropertyNames() {
@@ -62,13 +61,13 @@ public abstract class BaseProvider
     }
 
     public Subject resolveSubject(RequestContext request) {
-        Resolver<Subject,Request> subjectResolver = getSubjectResolver(request);
-        return subjectResolver != null ? subjectResolver.resolve(request) : null;
+        Function<Request,Subject> subjectResolver = getSubjectResolver(request);
+        return subjectResolver != null ? subjectResolver.apply(request) : null;
     }
 
     public Target resolveTarget(RequestContext request) {
-        Resolver<Target,RequestContext> targetResolver = getTargetResolver(request);
-        return targetResolver != null ? targetResolver.resolve(request) : null;
+        Function<RequestContext,Target> targetResolver = getTargetResolver(request);
+        return targetResolver != null ? targetResolver.apply(request) : null;
     }
 
     public String urlFor(Request request, Object key, Object param) {
@@ -76,13 +75,13 @@ public abstract class BaseProvider
         return tm != null ? tm.urlFor(request, key, param) : null;
     }
 
-    protected Resolver<Subject,Request> getSubjectResolver(RequestContext request) {
+    protected Function<Request,Subject> getSubjectResolver(RequestContext request) {
         return new SimpleSubjectResolver();
     }
 
     protected abstract TargetBuilder getTargetBuilder(Request request);
 
-    protected abstract Resolver<Target, RequestContext> getTargetResolver(RequestContext request);
+    protected abstract Function<RequestContext,Target> getTargetResolver(RequestContext request);
 
     public ResponseContext apply(RequestContext request) {
       Target target = request.getTarget();

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java Wed Oct 26 18:26:55 2011
@@ -22,7 +22,6 @@ import java.io.InputStream;
 import java.io.Reader;
 import java.security.Principal;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Locale;
 
 import javax.activation.MimeType;
@@ -46,8 +45,8 @@ public class BaseRequestContextWrapper
         this.request = request;
     }
 
-    public Object getAttribute(Scope scope, String name) {
-        return request.getAttribute(scope, name);
+    public <T>T getAttribute(Scope scope, String name) {
+        return request.<T>getAttribute(scope, name);
     }
 
     public Iterable<String> getAttributeNames(Scope scope) {
@@ -78,7 +77,7 @@ public class BaseRequestContextWrapper
         return request.getParameterNames();
     }
 
-    public List<String> getParameters(String name) {
+    public Iterable<String> getParameters(String name) {
         return request.getParameters(name);
     }
 
@@ -95,11 +94,11 @@ public class BaseRequestContextWrapper
     }
 
     public <T>T getProperty(Property property) {
-        return (T)request.getProperty(property);
+        return request.<T>getProperty(property);
     }
 
     public <P extends Provider>P getProvider() {
-        return (P)request.getProvider();
+        return request.<P>getProvider();
     }
 
     public Reader getReader() throws IOException {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java Wed Oct 26 18:26:55 2011
@@ -160,6 +160,11 @@ public class BaseResponseContextWrapper 
         response.setLocation(uri);
         return (T)this;
     }
+    
+    public <T extends ResponseContext>T setLocation(IRI iri) {
+      response.setLocation(iri);
+      return (T)this;
+    }
 
     public <T extends ResponseContext>T setSlug(String slug) {
         response.setSlug(slug);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionRequestProcessor.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionRequestProcessor.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionRequestProcessor.java Wed Oct 26 18:26:55 2011
@@ -24,7 +24,7 @@ import com.google.common.base.Predicate;
  * {@link org.apache.AtompubRequestProcessor.protocol.server.RequestProcessor} implementation which processes requests for collection
  * documents.
  */
-public abstract class CollectionRequestProcessor
+public class CollectionRequestProcessor
   extends TransactionalRequestProcessor {
 
   public CollectionRequestProcessor(

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java Wed Oct 26 18:26:55 2011
@@ -21,6 +21,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.abdera2.common.misc.Chain;
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.misc.Task;
 
 /**
@@ -47,28 +48,35 @@ public class MethodOverrideFilter implem
           this.methods.add(method);
     }
 
-    public ResponseContext apply(RequestContext request, Chain<RequestContext,ResponseContext> chain) {
-        return chain.next(new MethodOverrideRequestContext(request));
+    public ResponseContext apply(
+      RequestContext request, 
+      Chain<RequestContext,ResponseContext> chain) {
+        return chain.next(
+          new MethodOverrideRequestContext(
+            request,methods));
     }
 
-    private class MethodOverrideRequestContext extends BaseRequestContextWrapper {
-
+    private static class MethodOverrideRequestContext 
+      extends BaseRequestContextWrapper {
         private final String method;
-
-        public MethodOverrideRequestContext(RequestContext request) {
+        public MethodOverrideRequestContext(
+          RequestContext request, 
+          Set<String> methods) {
             super(request);
             String method = super.getMethod();
-            String xheader = getHeader("X-HTTP-Method-Override");
-            if (xheader == null)
-                xheader = getHeader("X-Method-Override");
+            String xheader = 
+              MoreFunctions
+                .<String>firstNonNull(
+                  getHeader("X-HTTP-Method-Override"),
+                  getHeader("X-Method-Override"));
             if (xheader != null)
                 xheader = xheader.toUpperCase().trim();
-            if (method.equals("POST") && xheader != null && methods.contains(method)) {
-                method = xheader;
-            }
+            if (method.equals("POST") && 
+                xheader != null && 
+                methods.contains(method))
+                  method = xheader;
             this.method = method;
         }
-
         public String getMethod() {
             return method;
         }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Provider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Provider.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Provider.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Provider.java Wed Oct 26 18:26:55 2011
@@ -21,6 +21,7 @@ import java.util.Map;
 
 import javax.security.auth.Subject;
 
+import org.apache.abdera2.common.misc.Initializable;
 import org.apache.abdera2.common.misc.Task;
 
 import com.google.common.base.Function;
@@ -32,12 +33,9 @@ import com.google.common.base.Function;
  */
 @SuppressWarnings("rawtypes")
 public interface Provider
-  extends TargetBuilder, Function<RequestContext,ResponseContext> {
-
-    /**`
-     * Initialize the Provider.
-     */
-    void init(Map<String, String> properties);
+  extends TargetBuilder, 
+          Function<RequestContext,ResponseContext>, 
+          Initializable {
 
     /**
      * Get the specified property

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RegexTargetResolver.java Wed Oct 26 18:26:55 2011
@@ -24,10 +24,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
-import org.apache.abdera2.common.misc.AbstractResolver;
-import org.apache.abdera2.common.misc.Resolver;
-
+import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.LinkedHashMultimap;
 import com.google.common.collect.Multimap;
@@ -57,8 +54,7 @@ import static org.apache.abdera2.common.
  * </pre>
  */
 public class RegexTargetResolver<R extends RequestContext>
-  extends AbstractResolver<Target,R>
-  implements Resolver<Target,R> {
+  implements Function<R,Target> {
 
     protected final Map<Pattern, TargetType> patterns;
     protected final Multimap<Pattern,String> fields = 
@@ -87,7 +83,7 @@ public class RegexTargetResolver<R exten
         return this;
     }
 
-    public Target resolve(R request) {
+    public Target apply(R request) {
         String uri = request.getTargetPath();
         for (Pattern pattern : patterns.keySet()) {
             Matcher matcher = pattern.matcher(uri);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestContext.java Wed Oct 26 18:26:55 2011
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
 import java.security.Principal;
-import java.util.List;
 import java.util.Locale;
 
 import javax.security.auth.Subject;
@@ -141,12 +140,12 @@ public interface RequestContext
     /**
      * Return all the values for the specified parameter
      */
-    List<String> getParameters(String name);
+    Iterable<String> getParameters(String name);
 
     /**
      * Get the named attribute from the specified scope
      */
-    Object getAttribute(Scope scope, String name);
+    <T>T getAttribute(Scope scope, String name);
 
     /**
      * Return the list of attribute names in the specified scope

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=1189362&r1=1189361&r2=1189362&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 Wed Oct 26 18:26:55 2011
@@ -85,11 +85,12 @@ public abstract class RequestProcessor 
         final Constructor<T> c = 
           _class.getConstructor(
             WorkspaceManager.class,
-            CollectionAdapter.class);
+            CollectionAdapter.class,
+            Predicate.class);
         return new RequestProcessorSupplier<T>(workspaceManager) {
           public T apply(CollectionAdapter adapter) {
             try {
-              return c.newInstance(workspaceManager,adapter);
+              return c.newInstance(workspaceManager,adapter,predicate);
             } catch (Throwable t) {
               throw ExceptionHelper.propogate(t);
             }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ResponseContext.java Wed Oct 26 18:26:55 2011
@@ -25,6 +25,7 @@ import org.apache.abdera2.common.http.Ca
 import org.apache.abdera2.common.http.EntityTag;
 import org.apache.abdera2.common.http.Preference;
 import org.apache.abdera2.common.http.WebLink;
+import org.apache.abdera2.common.iri.IRI;
 import org.joda.time.DateTime;
 
 /**
@@ -172,6 +173,11 @@ public interface ResponseContext extends
     <B extends ResponseContext>B setLocation(String uri);
 
     /**
+     * Set the value of the Location header
+     */
+    <B extends ResponseContext>B setLocation(IRI iri);
+    
+    /**
      * Set the response status code
      */
     <B extends ResponseContext>B setStatus(int status);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java Wed Oct 26 18:26:55 2011
@@ -26,14 +26,14 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.abdera2.common.misc.AbstractResolver;
-import org.apache.abdera2.common.misc.Resolver;
 import org.apache.abdera2.common.templates.CachingContext;
 import org.apache.abdera2.common.templates.Context;
 import org.apache.abdera2.common.templates.MapContext;
 import org.apache.abdera2.common.templates.ObjectContext;
 import org.apache.abdera2.common.templates.Route;
 
+import com.google.common.base.Function;
+
 /**
  * This is a largely experimental implementation of a Target Resolver and Target Builder based on URL patterns similar
  * (but not identical) to Ruby on Rails style routes. For instance:
@@ -47,8 +47,7 @@ import org.apache.abdera2.common.templat
  * The RouteManager can be used by Provider implementations as the target resolver and target builder
  */
 public class RouteManager<T,X extends RequestContext> 
-  extends AbstractResolver<Target,X>
-  implements Resolver<Target,X>, 
+  implements Function<X,Target>, 
              TargetBuilder<T> {
 
     protected class RouteTargetType {
@@ -101,7 +100,7 @@ public class RouteManager<T,X extends Re
         return addRoute(route, type);
     }
 
-    public Target resolve(X request) {
+    public Target apply(X request) {
         String uri = request.getTargetPath();
         int idx = uri.indexOf('?');
         if (idx != -1) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ServiceManager.java Wed Oct 26 18:26:55 2011
@@ -26,30 +26,25 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.pusher.ChannelManager;
 
 @DefaultImplementation("org.apache.abdera2.protocol.server.AtompubServiceManager")
-public interface ServiceManager<P extends Provider> {
-
-  public static final String PROVIDER = Provider.class.getName();
-  public static final String PROCESSORQUEUE = ProcessorQueue.class.getName();
-  public static final String TASKEXECUTOR = TaskExecutor.class.getName();
-  public static final String CHANNELMANAGER = ChannelManager.class.getName();
-
+public interface ServiceManager {
   
-  public abstract P newProvider(Map<String, String> properties);
+  public abstract <P extends Provider>P newProvider(
+    Map<String, Object> properties);
 
   public abstract ProcessorQueue newProcessorQueue(
-      Map<String, String> properties);
+    Map<String, Object> properties);
 
-  public abstract TaskExecutor newTaskExecutor(Map<String, String> properties);
+  public abstract TaskExecutor newTaskExecutor(
+    Map<String, Object> properties);
 
   public abstract ChannelManager newChannelManager(
-      Map<String, String> properties);
+      Map<String, Object> properties);
 
-  @SuppressWarnings({"rawtypes" })
   public static class Factory {
     
-    @SuppressWarnings("unchecked")
-    public static ServiceManager<Provider> getInstance() {
-      return getInstance("org.apache.abdera2.protocol.server.AtompubServiceManager");
+    public static ServiceManager getInstance() {
+      return getInstance(
+        "org.apache.abdera2.protocol.server.AtompubServiceManager");
     }
   
     public static ServiceManager getInstance(String impl) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java Wed Oct 26 18:26:55 2011
@@ -22,33 +22,31 @@ import java.security.Principal;
 
 import javax.security.auth.Subject;
 
-import org.apache.abdera2.common.misc.AbstractResolver;
-import org.apache.abdera2.common.misc.Resolver;
+import com.google.common.base.Function;
 
 /**
  * The default subject resolver implementation
  */
 public class SimpleSubjectResolver 
-  extends AbstractResolver<Subject,Request>
-  implements Resolver<Subject,Request> {
+  implements Function<Request,Subject> {
 
     public static final Principal ANONYMOUS = new AnonymousPrincipal();
 
-    public Subject resolve(Request request) {
+    public Subject apply(Request request) {
         RequestContext context = (RequestContext)request;
-        return resolve(context.getPrincipal());
+        return apply(context.getPrincipal());
     }
 
-    public Subject resolve(Principal principal) {
+    public Subject apply(Principal principal) {
         Subject subject = new Subject();
         subject.getPrincipals().add((principal != null) ? principal : ANONYMOUS);
         return subject;
     }
 
-    public Subject resolve(String userid) {
+    public Subject apply(String userid) {
         if (userid == null)
-            return resolve(ANONYMOUS);
-        return resolve(new SimplePrincipal(userid));
+            return apply(ANONYMOUS);
+        return apply(new SimplePrincipal(userid));
     }
 
     static class SimplePrincipal implements Principal, Serializable {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetFunctionResolver.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetFunctionResolver.java?rev=1189362&r1=1189361&r2=1189362&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetFunctionResolver.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TargetFunctionResolver.java Wed Oct 26 18:26:55 2011
@@ -10,9 +10,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.abdera2.common.iri.IRI;
-import org.apache.abdera2.common.misc.AbstractResolver;
 import org.apache.abdera2.common.misc.ExceptionHelper;
-import org.apache.abdera2.common.misc.Resolver;
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.base.Supplier;
@@ -26,8 +24,7 @@ import com.google.common.collect.Iterabl
  * function in the list is tried
  */
 public class TargetFunctionResolver<R extends RequestContext>
-  extends AbstractResolver<Target,R>
-  implements Resolver<Target,R> {
+  implements Function<R,Target> {
 
   public static <R extends RequestContext>TargetFunctionResolver<R> create(
     TargetFunction<R>... functions) {
@@ -53,7 +50,7 @@ public class TargetFunctionResolver<R ex
       return this;
   }
 
-  public Target resolve(R request) {
+  public Target apply(R request) {
     for (TargetFunction<R> f : functions) {
       Target target = f.apply(request);
       if (target != null)



Mime
View raw message