abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1173209 [7/49] - in /abdera/abdera2: ./ .settings/ activities/ activities/src/ activities/src/main/ activities/src/main/java/ activities/src/main/java/org/ activities/src/main/java/org/apache/ activities/src/main/java/org/apache/abdera2/ a...
Date Tue, 20 Sep 2011 15:57:20 GMT
Added: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestHelper.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestHelper.java (added)
+++ abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestHelper.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.client;
+
+import java.net.URI;
+
+import org.apache.abdera2.common.http.CacheControl;
+import org.apache.abdera2.common.http.Method;
+
+import static org.apache.abdera2.common.http.Method.GET;
+import static org.apache.abdera2.common.http.Method.POST;
+import static org.apache.abdera2.common.http.Method.PUT;
+import static org.apache.abdera2.common.http.Method.DELETE;
+import static org.apache.abdera2.common.http.Method.OPTIONS;
+import static org.apache.abdera2.common.http.Method.PATCH;
+import static org.apache.abdera2.common.http.Method.HEAD;
+import static org.apache.abdera2.common.http.Method.TRACE;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpRequest;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.client.methods.HttpOptions;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpTrace;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.params.ClientPNames;
+import org.apache.http.params.CoreProtocolPNames;
+import org.apache.http.params.HttpParams;
+
+public class RequestHelper {
+
+    public static HttpUriRequest createRequest(
+      String method, 
+      String uri, 
+      HttpEntity entity, 
+      RequestOptions options) {
+        if (method == null)
+            return null;
+        if (options == null)
+          options = createDefaultRequestOptions();
+        Method m = Method.get(method);
+        Method actual = null;
+        HttpUriRequest httpMethod = null;
+        if (options.isUsePostOverride()) {
+            if (m.equals(Method.PUT)) {
+                actual = m;
+            } else if (m.equals(Method.DELETE)) {
+                actual = m;
+            }
+            if (actual != null)
+                m = Method.POST;
+        }
+        if (m == GET) {
+          httpMethod = new HttpGet(uri);
+        } else if (m == POST) {
+          httpMethod = new HttpPost(uri);
+          if (entity != null) 
+            ((HttpPost)httpMethod).setEntity(entity);
+        } else if (m == PUT) {
+          httpMethod = new HttpPut(uri);
+          if (entity != null)
+            ((HttpPut)httpMethod).setEntity(entity);
+        } else if (m == DELETE) {
+          httpMethod = new HttpDelete(uri);
+        } else if (m == HEAD) {
+          httpMethod = new HttpHead(uri);
+        } else if (m == OPTIONS) {
+          httpMethod = new HttpOptions(uri);
+        } else if (m == TRACE) {
+          httpMethod = new HttpTrace(uri);
+        } else if (m == PATCH) {
+          httpMethod = new ExtensionRequest(m.name(),uri,entity);
+        } else {
+          httpMethod = new ExtensionRequest(m.name(),uri,entity);
+        }
+        if (actual != null) {
+            httpMethod.addHeader("X-HTTP-Method-Override", actual.name());
+        }
+        initHeaders(options, httpMethod);
+
+        HttpParams params = httpMethod.getParams();
+        if (!options.isUseExpectContinue())
+          params.setBooleanParameter(
+              CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
+        if (!(httpMethod instanceof HttpEntityEnclosingRequest))
+            params.setBooleanParameter(
+              ClientPNames.HANDLE_REDIRECTS, options.isFollowRedirects()); 
+        return httpMethod;
+    }
+
+    private static void initHeaders(RequestOptions options, HttpRequest request) {
+        Iterable<String> headers = options.getHeaderNames();
+        for (String header : headers) {
+            Iterable<Object> values = options.getHeaders(header);
+            for (Object value : values) {
+                request.addHeader(header, value.toString());
+            }
+        }
+        CacheControl cc = options.getCacheControl();
+        if (cc != null) { 
+            String scc = cc.toString();
+            if (scc.length() > 0)
+              request.setHeader("Cache-Control", scc);
+        }
+// TODO: Authentication setup per request???
+//        if (options.getAuthorization() != null)
+//            method.setDoAuthentication(false);
+    }
+
+    public static class ExtensionRequest 
+      extends HttpEntityEnclosingRequestBase {
+      private final String method;
+      public ExtensionRequest(String method, String uri, HttpEntity entity) {
+        try {
+          super.setURI(new URI(uri));
+        } catch (Throwable t) {
+          throw new IllegalArgumentException(t);
+        }
+        this.method = method;
+        if (entity != null)
+          setEntity(entity);
+      }
+      public String getMethod() {
+        return method;
+      }
+      
+    }
+    
+    public static RequestOptions createDefaultRequestOptions() {
+        RequestOptions options = new RequestOptions();
+        options.setAcceptEncoding("gzip", "deflate");
+        options.setAccept("application/atom+xml;type=entry",
+                          "application/atom+xml;type=feed",
+                          "application/atom+xml",
+                          "application/atomsvc+xml",
+                          "application/atomcat+xml",
+                          "application/xml;q=0.5",
+                          "text/xml;q=0.5",
+                          "*/*;q=0.01");
+        options.setAcceptCharset("utf-8", "*;q=0.5");
+        return options;
+    }
+}

Propchange: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestOptions.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestOptions.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestOptions.java (added)
+++ abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestOptions.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,642 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.client;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera2.common.Localizer;
+import org.apache.abdera2.common.lang.Lang;
+import org.apache.abdera2.common.protocol.AbstractRequest;
+import org.apache.abdera2.common.protocol.Request;
+import org.apache.abdera2.common.text.Codec;
+import org.apache.abdera2.common.text.UrlEncoding;
+import org.apache.abdera2.common.text.CharUtils.Profile;
+import org.apache.abdera2.common.http.CacheControl;
+import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.http.Preference;
+import org.apache.abdera2.common.http.WebLink;
+import org.apache.http.impl.cookie.DateParseException;
+import org.apache.http.impl.cookie.DateUtils;
+
+/**
+ * The RequestOptions class allows a variety of options affecting the execution of the request to be modified.
+ */
+public class RequestOptions extends AbstractRequest implements Request {
+
+    private boolean noLocalCache = false;
+    private boolean revalidateAuth = false;
+    private boolean useChunked = false;
+    private boolean usePostOverride = false;
+    private boolean requestException4xx = false;
+    private boolean requestException5xx = false;
+    private boolean useExpectContinue = true;
+    private boolean useConditional = true;
+    private boolean followRedirects = true;
+    private CacheControl cacheControl = null;
+
+    private final Map<String, Set<String>> headers = 
+      new HashMap<String, Set<String>>();
+
+    public RequestOptions() {
+    }
+
+    /**
+     * Create the RequestOptions object with the specified If-Modified-Since header value
+     * 
+     * @param ifModifiedSince
+     */
+    public RequestOptions(Date ifModifiedSince) {
+        this();
+        setIfModifiedSince(ifModifiedSince);
+    }
+
+    /**
+     * Create the RequestOptions object with the specified If-None-Match header value
+     * 
+     * @param IfNoneMatch
+     */
+    public RequestOptions(String ifNoneMatch) {
+        this();
+        setIfNoneMatch(ifNoneMatch);
+    }
+
+    /**
+     * Create the RequestOptions object with the specified If-None-Match header value
+     * 
+     * @param IfNoneMatch
+     */
+    public RequestOptions(String etag, String... ifNoneMatch) {
+        this();
+        setIfNoneMatch(etag, ifNoneMatch);
+    }
+
+    /**
+     * Create the RequestOptions object with the specified If-Modified-Since and If-None-Match header values
+     * 
+     * @param ifModifiedSince
+     * @param IfNoneMatch
+     */
+    public RequestOptions(Date ifModifiedSince, String ifNoneMatch) {
+        this();
+        setIfModifiedSince(ifModifiedSince);
+        setIfNoneMatch(ifNoneMatch);
+    }
+
+    /**
+     * Create the RequestOptions object with the specified If-Modified-Since and If-None-Match header values
+     * 
+     * @param ifModifiedSince
+     * @param IfNoneMatch
+     */
+    public RequestOptions(Date ifModifiedSince, String etag, String... ifNoneMatch) {
+        this();
+        setIfModifiedSince(ifModifiedSince);
+        setIfNoneMatch(etag, ifNoneMatch);
+    }
+
+    /**
+     * Create the RequestOptions object
+     * 
+     * @param no_cache True if the request will indicate that cached responses should not be returned
+     */
+    public RequestOptions(boolean no_cache) {
+        this();
+        setCacheControl(CacheControl.NOCACHE());
+        noLocalCache = true;
+    }
+
+    private Map<String, Set<String>> getHeaders() {
+        return headers;
+    }
+
+    private String combine(String... values) {
+        StringBuilder v = new StringBuilder();
+        for (String val : values) {
+            if (v.length() > 0)
+                v.append(", ");
+            v.append(val);
+        }
+        return v.toString();
+    }
+
+    /**
+     * The difference between this and getNoCache is that this only disables the local cache without affecting the
+     * Cache-Control header.
+     */
+    public boolean getUseLocalCache() {
+        return !noLocalCache;
+    }
+
+    /**
+     * True if the local client cache should be used
+     */
+    public RequestOptions setUseLocalCache(boolean use_cache) {
+        this.noLocalCache = !use_cache;
+        return this;
+    }
+
+    /**
+     * Set the value of the HTTP Content-Type header
+     */
+    public RequestOptions setContentType(String value) {
+        return setHeader("Content-Type", value);
+    }
+
+    public RequestOptions setContentLocation(String iri) {
+        return setHeader("Content-Location", iri);
+    }
+
+    /**
+     * Set the value of the HTTP Content-Type header
+     */
+    public RequestOptions setContentType(MimeType value) {
+        return setHeader("Content-Type", value.toString());
+    }
+
+    /**
+     * Set the value of the HTTP Authorization header
+     */
+    public RequestOptions setAuthorization(String auth) {
+        return setHeader("Authorization", auth);
+    }
+
+    /**
+     * Set the value of a header using proper encoding of non-ascii characters
+     */
+    public RequestOptions setEncodedHeader(String header, String charset, String value) {
+        return setHeader(header, Codec.encode(value, charset));
+    }
+
+    /**
+     * Set the values of a header using proper encoding of non-ascii characters
+     */
+    public RequestOptions setEncodedHeader(String header, String charset, String... values) {
+        if (values != null && values.length > 0) {
+            Set<String> vals = new HashSet<String>();
+            for (String value : values) 
+              vals.add(Codec.encode(value,charset));
+            getHeaders().put(header, vals);
+        } else {
+            removeHeaders(header);
+        }
+        return this;
+    }
+
+    /**
+     * Set the value of the specified HTTP header
+     */
+    public RequestOptions setHeader(String header, String value) {
+        return value != null ? setHeader(header, new String[] {value}) : removeHeaders(header);
+    }
+
+    /**
+     * Set the value of the specified HTTP header
+     */
+    public RequestOptions setHeader(String header, String... values) {
+        if (values != null && values.length > 0) {
+            Set<String> vals = new HashSet<String>();
+            vals.add(combine(values));
+            getHeaders().put(header, vals);
+        } else {
+            removeHeaders(header);
+        }
+        return this;
+    }
+
+    /**
+     * Set the date value of the specified HTTP header
+     */
+    public RequestOptions setDateHeader(String header, Date value) {
+        return value != null ? setHeader(header, DateUtils.formatDate(value)) : removeHeaders(header);
+    }
+
+    /**
+     * Similar to setEncodedHeader, but allows for multiple instances of the specified header
+     */
+    public RequestOptions addEncodedHeader(String header, String charset, String value) {
+        return addHeader(header, Codec.encode(value, charset));
+    }
+
+    /**
+     * Similar to setEncodedHeader, but allows for multiple instances of the specified header
+     */
+    public RequestOptions addEncodedHeader(String header, String charset, String... values) {
+        if (values == null || values.length == 0)
+            return this;
+        for (int n = 0; n < values.length; n++) {
+            values[n] = Codec.encode(values[n], charset);
+        }
+        Set<String> list = getHeaders().get(header);
+        String value = combine(values);
+        if (list != null)
+          list.add(value);
+        else
+          setHeader(header, new String[] {value});
+        return this;
+    }
+
+    /**
+     * Similar to setHeader but allows for multiple instances of the specified header
+     */
+    public RequestOptions addHeader(String header, String value) {
+        if (value != null)
+            addHeader(header, new String[] {value});
+        return this;
+    }
+
+    /**
+     * Similar to setHeader but allows for multiple instances of the specified header
+     */
+    public RequestOptions addHeader(String header, String... values) {
+        if (values == null || values.length == 0)
+            return this;
+        Set<String> headers = getHeaders().get(header);
+        String value = combine(values);
+        if (headers != null)
+          headers.add(value);
+        else
+            setHeader(header, new String[] {value});
+        return this;
+    }
+
+    /**
+     * Similar to setDateHeader but allows for multiple instances of the specified header
+     */
+    public RequestOptions addDateHeader(String header, Date value) {
+        if (value == null)
+            return this;
+        return addHeader(header, DateUtils.formatDate(value));
+    }
+
+    /**
+     * Returns the text value of the specified header
+     */
+    public String getHeader(String header) {
+        Set<String> list = getHeaders().get(header);
+        return list.size() > 0 ? list.iterator().next() : null;
+    }
+
+    /**
+     * Return a listing of text values for the specified header
+     */
+    public Iterable<Object> getHeaders(String header) {
+        Set<String> headers = getHeaders().get(header);
+        return new HashSet<Object>(headers);
+    }
+
+    /**
+     * Returns the date value of the specified header
+     */
+    public Date getDateHeader(String header) {
+        String val = getHeader(header);
+        try {
+            return (val != null) ? DateUtils.parseDate(val) : null;
+        } catch (DateParseException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Returns a listing of header names
+     */
+    public Iterable<String> getHeaderNames() {
+        return getHeaders().keySet();
+    }
+
+    /**
+     * Sets the value of the HTTP If-Match header
+     */
+    public RequestOptions setIfMatch(String entity_tag) {
+        return setIfMatch(new EntityTag(entity_tag));
+    }
+
+    /**
+     * Sets the value of the HTTP If-Match header
+     */
+    public RequestOptions setIfMatch(EntityTag entity_tag) {
+        return setHeader("If-Match", entity_tag.toString());
+    }
+
+    /**
+     * Sets the value of the HTTP If-Match header
+     */
+    public RequestOptions setIfMatch(EntityTag tag, EntityTag... entity_tags) {
+        return setHeader("If-Match", EntityTag.toString(tag,entity_tags));
+    }
+
+    /**
+     * Sets the value of the HTTP If-Match header
+     */
+    public RequestOptions setIfMatch(String etag, String... entity_tags) {
+        return setHeader("If-Match", EntityTag.toString(etag, entity_tags));
+    }
+
+    /**
+     * Sets the value of the HTTP If-None-Match header
+     */
+    public RequestOptions setIfNoneMatch(String entity_tag) {
+        return setIfNoneMatch(new EntityTag(entity_tag));
+    }
+
+    /**
+     * Sets the value of the HTTP If-None-Match header
+     */
+    public RequestOptions setIfNoneMatch(EntityTag entity_tag) {
+        return setHeader("If-None-Match", entity_tag.toString());
+    }
+
+    /**
+     * Sets the value of the HTTP If-None-Match header
+     */
+    public RequestOptions setIfNoneMatch(EntityTag etag, EntityTag... entity_tags) {
+        return setHeader("If-None-Match", EntityTag.toString(etag, entity_tags));
+    }
+
+    /**
+     * Sets the value of the HTTP If-None-Match header
+     */
+    public RequestOptions setIfNoneMatch(String etag, String... entity_tags) {
+        return setHeader("If-None-Match", EntityTag.toString(etag, entity_tags));
+    }
+
+    /**
+     * Sets the value of the HTTP If-Modified-Since header
+     */
+    public RequestOptions setIfModifiedSince(Date date) {
+        return setDateHeader("If-Modified-Since", date);
+    }
+
+    /**
+     * Sets the value of the HTTP If-Unmodified-Since header
+     */
+    public RequestOptions setIfUnmodifiedSince(Date date) {
+        return setDateHeader("If-Unmodified-Since", date);
+    }
+
+    /**
+     * Sets the value of the HTTP Accept header
+     */
+    public RequestOptions setAccept(String accept) {
+        return setAccept(new String[] {accept});
+    }
+
+    /**
+     * Sets the value of the HTTP Accept header
+     */
+    public RequestOptions setAccept(String... accept) {
+        return setHeader("Accept", combine(accept));
+    }
+
+    public RequestOptions setAcceptLanguage(Locale locale) {
+        return setAcceptLanguage(Lang.fromLocale(locale));
+    }
+
+    public RequestOptions setAcceptLanguage(Locale... locales) {
+        String[] langs = new String[locales.length];
+        for (int n = 0; n < locales.length; n++)
+            langs[n] = Lang.fromLocale(locales[n]);
+        setAcceptLanguage(langs);
+        return this;
+    }
+
+    /**
+     * Sets the value of the HTTP Accept-Language header
+     */
+    public RequestOptions setAcceptLanguage(String accept) {
+        return setAcceptLanguage(new String[] {accept});
+    }
+
+    /**
+     * Sets the value of the HTTP Accept-Language header
+     */
+    public RequestOptions setAcceptLanguage(String... accept) {
+        return setHeader("Accept-Language", combine(accept));
+    }
+
+    /**
+     * Sets the value of the HTTP Accept-Charset header
+     */
+    public RequestOptions setAcceptCharset(String accept) {
+        return setAcceptCharset(new String[] {accept});
+    }
+
+    /**
+     * Sets the value of the HTTP Accept-Charset header
+     */
+    public RequestOptions setAcceptCharset(String... accept) {
+        return setHeader("Accept-Charset", combine(accept));
+    }
+
+    /**
+     * Sets the value of the HTTP Accept-Encoding header
+     */
+    public RequestOptions setAcceptEncoding(String accept) {
+        return setAcceptEncoding(new String[] {accept});
+    }
+
+    /**
+     * Sets the value of the HTTP Accept-Encoding header
+     */
+    public RequestOptions setAcceptEncoding(String... accept) {
+        return setHeader("Accept-Encoding", combine(accept));
+    }
+
+    /**
+     * Sets the value of the Atom Publishing Protocol Slug header
+     */
+    public RequestOptions setSlug(String slug) {
+        if (slug.indexOf((char)10) > -1 || slug.indexOf((char)13) > -1)
+            throw new IllegalArgumentException(Localizer.get("SLUG.BAD.CHARACTERS"));
+        return setHeader("Slug", UrlEncoding.encode(slug, Profile.PATHNODELIMS));
+    }
+
+    /**
+     * Sets the value of the HTTP Cache-Control header
+     */
+    public RequestOptions setCacheControl(String cc) {
+        this.cacheControl = new CacheControl(cc);
+        return this;
+    }
+    
+    /**
+     * Sets the value of the HTTP Cache-Control header
+     */
+    public RequestOptions setCacheControl(CacheControl cc) {
+      this.cacheControl = cc;
+      return this;
+    }
+
+    /**
+     * Remove the specified HTTP header
+     */
+    public RequestOptions removeHeaders(String name) {
+        getHeaders().remove(name);
+        return this;
+    }
+
+    /**
+     * Return the value of the Cache-Control header
+     */
+    public CacheControl getCacheControl() {
+        return cacheControl;
+    }
+
+    /**
+     * Configure the AbderaClient Side cache to revalidate when using Authorization
+     */
+    public boolean getRevalidateWithAuth() {
+        return revalidateAuth;
+    }
+
+    /**
+     * Configure the AbderaClient Side cache to revalidate when using Authorization
+     */
+    public RequestOptions setRevalidateWithAuth(boolean revalidateAuth) {
+        this.revalidateAuth = revalidateAuth;
+        return this;
+    }
+
+    /**
+     * Should the request use chunked encoding?
+     */
+    public boolean isUseChunked() {
+        return useChunked;
+    }
+
+    /**
+     * Set whether the request should use chunked encoding.
+     */
+    public RequestOptions setUseChunked(boolean useChunked) {
+        this.useChunked = useChunked;
+        return this;
+    }
+
+    /**
+     * Set whether the request should use the X-HTTP-Method-Override option
+     */
+    public RequestOptions setUsePostOverride(boolean useOverride) {
+        this.usePostOverride = useOverride;
+        return this;
+    }
+
+    /**
+     * Return whether the request should use the X-HTTP-Method-Override option
+     */
+    public boolean isUsePostOverride() {
+        return this.usePostOverride;
+    }
+
+    /**
+     * Set whether or not to throw a RequestExeption on 4xx responses
+     */
+    public RequestOptions set4xxRequestException(boolean v) {
+        this.requestException4xx = v;
+        return this;
+    }
+
+    /**
+     * Return true if a RequestException should be thrown on 4xx responses
+     */
+    public boolean is4xxRequestException() {
+        return this.requestException4xx;
+    }
+
+    /**
+     * Set whether or not to throw a RequestExeption on 5xx responses
+     */
+    public RequestOptions set5xxRequestException(boolean v) {
+        this.requestException5xx = v;
+        return this;
+    }
+
+    /**
+     * Return true if a RequestException should be thrown on 5xx responses
+     */
+    public boolean is5xxRequestException() {
+        return this.requestException5xx;
+    }
+
+    /**
+     * Set whether or not to use the HTTP Expect-Continue mechanism (enabled by default)
+     */
+    public RequestOptions setUseExpectContinue(boolean useExpect) {
+        this.useExpectContinue = useExpect;
+        return this;
+    }
+
+    /**
+     * Return true if Expect-Continue should be used
+     */
+    public boolean isUseExpectContinue() {
+        return this.useExpectContinue;
+    }
+
+    /**
+     * True if HTTP Conditional Requests should be used automatically. This only has an effect when putting a Document
+     * that has an ETag or Last-Modified date present
+     */
+    public boolean isConditionalPut() {
+        return this.useConditional;
+    }
+
+    /**
+     * True if HTTP Conditinal Request should be used automatically. This only has an effect when putting a Document
+     * that has an ETag or Last-Modified date present
+     */
+    public RequestOptions setConditionalPut(boolean conditional) {
+        this.useConditional = conditional;
+        return this;
+    }
+
+    /**
+     * True if the client should follow redirects automatically
+     */
+    public boolean isFollowRedirects() {
+        return followRedirects;
+    }
+
+    /**
+     * True if the client should follow redirects automatically
+     */
+    public RequestOptions setFollowRedirects(boolean followredirects) {
+        this.followRedirects = followredirects;
+        return this;
+    }
+    
+    public RequestOptions setWebLinks(WebLink weblink, WebLink... links) {
+      setHeader("Link", WebLink.toString(weblink,links));
+      return this;
+    }
+    
+    public RequestOptions setPrefer(Preference pref, Preference... prefs) {
+      setHeader("Prefer", Preference.toString(pref, prefs));
+      return this;
+    }
+    
+    public RequestOptions setPreferApplied(Preference pref, Preference... prefs) {
+      setHeader("Preference-Applied", Preference.toString(pref, prefs));
+      return this;
+    }
+}

Propchange: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/RequestOptions.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Session.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Session.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Session.java (added)
+++ abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Session.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,357 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.protocol.client;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.abdera2.common.http.Method;
+import org.apache.abdera2.common.http.ResponseType;
+import org.apache.abdera2.common.protocol.ProtocolException;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.client.AuthCache;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.protocol.ClientContext;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
+
+/**
+ * A client session. Session's MUST NOT be used by more
+ * than one Thread of execution as a time as multiple threads would stomp 
+ * all over the shared session context. It is critical to completely
+ * consume each ClientResponse before executing an additional request on 
+ * the same session.
+ */
+public class Session {
+
+    protected final Client client;
+    protected final HttpContext localContext;
+
+    protected Session(Client client) {
+        this.client = client;
+        this.localContext = 
+          new BasicHttpContext();
+    }
+    
+    private HttpClient getClient() {
+      return client.getClient();
+    }
+    
+    @SuppressWarnings("unchecked")
+    protected <T extends ClientResponse>T wrap(ClientResponse resp) {
+      return (T)resp;
+    }
+    
+    /**
+     * Sends an HTTP HEAD request to the specified URI.
+     * 
+     * @param uri The request URI
+     * @param options The request options
+     */
+    public <T extends ClientResponse>T head(String uri, RequestOptions options) {
+        return wrap(execute("HEAD", uri, (HttpEntity)null, options));
+    }
+    
+    /**
+     * Sends an HTTP GET request to the specified URI.
+     * 
+     * @param uri The request URI
+     * @param options The request options
+     */
+    public <T extends ClientResponse>T get(String uri, RequestOptions options) {
+        return wrap(execute("GET", uri, (HttpEntity)null, options));
+    }
+
+    /**
+     * Sends an HTTP POST request to the specified URI.
+     * 
+     * @param uri The request URI
+     * @param entity A RequestEntity object providing the payload of the request
+     * @param options The request options
+     */
+    public <T extends ClientResponse>T post(String uri, HttpEntity entity, RequestOptions options) {
+        return wrap(execute("POST", uri, entity, options));
+    }
+
+    /**
+     * Sends an HTTP POST request to the specified URI.
+     * 
+     * @param uri The request URI
+     * @param in An InputStream providing the payload of the request
+     * @param options The request options
+     */
+    public <T extends ClientResponse>T post(String uri, InputStream in, RequestOptions options) {
+        return wrap(execute("POST", uri, new InputStreamEntity(in,-1), options));
+    }
+
+    /**
+     * Sends an HTTP PUT request to the specified URI.
+     * 
+     * @param uri The request URI
+     * @param entity A RequestEntity object providing the payload of the request
+     * @param options The request options
+     */
+    public <T extends ClientResponse>T put(String uri, HttpEntity entity, RequestOptions options) {
+        return wrap(execute("PUT", uri, entity, options));
+    }
+
+    /**
+     * Sends an HTTP PUT request to the specified URI.
+     * 
+     * @param uri The request URI
+     * @param in An InputStream providing the payload of the request
+     * @param options The request options
+     */
+    public <T extends ClientResponse>T put(String uri, InputStream in, RequestOptions options) {
+        return wrap(execute("PUT", uri, new InputStreamEntity(in,-1), options));
+    }
+
+    /**
+     * Sends an HTTP DELETE request to the specified URI.
+     * 
+     * @param uri The request URI
+     * @param options The request options
+     */
+    public <T extends ClientResponse>T delete(String uri, RequestOptions options) {
+        return wrap(execute("DELETE", uri, (HttpEntity)null, options));
+    }
+
+    /**
+     * Sends an HTTP HEAD request to the specified URI using the default options
+     * 
+     * @param uri The request URI
+     */
+    public <T extends ClientResponse>T head(String uri) {
+        return wrap(head(uri, getDefaultRequestOptions()));
+    }
+
+    /**
+     * Sends an HTTP GET request to the specified URI using the default options
+     * 
+     * @param uri The request URI
+     */
+    public <T extends ClientResponse>T get(String uri) {
+        return wrap(get(uri, getDefaultRequestOptions()));
+    }
+
+    /**
+     * Sends an HTTP POST request to the specified URI using the default options
+     * 
+     * @param uri The request URI
+     * @param entity A RequestEntity object providing the payload of the request
+     */
+    public <T extends ClientResponse>T post(String uri, HttpEntity entity) {
+        return wrap(post(uri, entity, getDefaultRequestOptions()));
+    }
+
+    /**
+     * Sends an HTTP POST request to the specified URI using the default options
+     * 
+     * @param uri The request URI
+     * @param in An InputStream providing the payload of the request
+     */
+    public <T extends ClientResponse>T post(String uri, InputStream in) {
+        return wrap(post(uri, in, getDefaultRequestOptions()));
+    }
+
+    /**
+     * Sends an HTTP PUT request to the specified URI using the default options
+     * 
+     * @param uri The request URI
+     * @param entity A RequestEntity object providing the payload of the request
+     */
+    public <T extends ClientResponse>T put(String uri, HttpEntity entity) {
+        return wrap(put(uri, entity, getDefaultRequestOptions()));
+    }
+
+    /**
+     * Sends an HTTP PUT request to the specified URI using the default options
+     * 
+     * @param uri The request URI
+     * @param in An InputStream providing the payload of the request
+     */
+    public <T extends ClientResponse>T put(String uri, InputStream in) {
+        return wrap(put(uri, in, getDefaultRequestOptions()));
+    }
+
+    /**
+     * Sends an HTTP DELETE request to the specified URI using the default options
+     * 
+     * @param uri The request URI
+     */
+    public <T extends ClientResponse>T delete(String uri) {
+        return wrap(delete(uri, getDefaultRequestOptions()));
+    }
+    
+    /**
+     * Sends the specified method request to the specified URI. This can be used to send extension HTTP methods to a
+     * server (e.g. PATCH, LOCK, etc)
+     * 
+     * @param method The HTTP method
+     * @param uri The request URI
+     * @param in An InputStream providing the payload of the request
+     * @param options The Request Options
+     */
+    public <T extends ClientResponse>T execute(
+        String method, 
+        String uri, 
+        InputStream in, 
+        RequestOptions options) {
+        if (options == null)
+          options = getDefaultRequestOptions();
+        InputStreamEntity re = 
+          new InputStreamEntity(in, -1);
+        re.setContentType(
+          options.getContentType().toString());
+        return wrap(execute(
+          method, uri, re, options));
+    }
+    
+    /**
+     * Sends the specified method request to the specified URI. This can be used to send extension HTTP methods to a
+     * server (e.g. PATCH, LOCK, etc)
+     * 
+     * @param method The HTTP method
+     * @param uri The request URI
+     * @param in An InputStream providing the payload of the request
+     * @param options The Request Options
+     */
+    public <T extends ClientResponse>T execute(
+        Method method, 
+        String uri, 
+        InputStream in, 
+        RequestOptions options) {
+        return wrap(execute(method.name(),uri,in,options));
+    }
+
+    public <T extends ClientResponse>T execute(
+        Method method, 
+        String uri, 
+        HttpEntity entity, 
+        RequestOptions options) {
+      return wrap(execute(method.name(),uri,entity,options));
+    }
+    
+    /**
+     * Sends the specified method request to the specified URI. This can be used to send extension HTTP methods to a
+     * server (e.g. PATCH, LOCK, etc)
+     * 
+     * @param method The HTTP method
+     * @param uri The request URI
+     * @param entity A RequestEntity object providing the payload for the request
+     * @param options The Request Options
+     */
+    public <T extends ClientResponse>T execute(
+        String method, 
+        String uri, 
+        HttpEntity entity, 
+        RequestOptions options) {
+        options =
+          options != null ? 
+            options : 
+            getDefaultRequestOptions();
+        try {
+            HttpUriRequest request = 
+              RequestHelper.createRequest(
+                  method, uri, entity, options);
+            HttpResponse response = 
+              getClient().execute(request, localContext);
+            ClientResponse resp = 
+              wrap(new ClientResponseImpl(
+                this, response, method, localContext));
+            return checkRequestException(resp, options);
+        } catch (RuntimeException r) {
+            throw r;
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <T extends ClientResponse>T checkRequestException(ClientResponse response, RequestOptions options) {
+      if (response == null)
+          return (T)response;
+      ResponseType type = response.getType();
+      if ((type.equals(ResponseType.CLIENT_ERROR) && options.is4xxRequestException()) || (type
+          .equals(ResponseType.SERVER_ERROR) && options.is5xxRequestException())) {
+        throw new ProtocolException(response.getStatus(),response.getStatusText());
+      }
+      return (T)response;
+  }
+    
+    /**
+     * Get a copy of the default request options
+     */
+    public RequestOptions getDefaultRequestOptions() {
+        return RequestHelper.createDefaultRequestOptions();
+    }
+
+    public void usePreemptiveAuthentication(String target, String realm) throws URISyntaxException {
+        AuthCache cache = (AuthCache) localContext.getAttribute(ClientContext.AUTH_CACHE);
+        if (cache == null) {
+          String host = AuthScope.ANY_HOST;
+          int port = AuthScope.ANY_PORT;
+          if (target != null) {
+              URI uri = new URI(target);
+              host = uri.getHost();
+              port = uri.getPort();
+          }
+          BasicScheme basicAuth = new BasicScheme();
+          HttpHost targetHost = 
+            new HttpHost(host,port,basicAuth.getSchemeName());
+          cache = new BasicAuthCache();
+          cache.put(targetHost, basicAuth);
+          localContext.setAttribute(ClientContext.AUTH_CACHE, cache);
+        }
+    }
+    
+    public void doFormLogin(String uri, String userid, String password) {
+      doFormLogin(uri, "j_username", userid, "j_password", password);
+    }
+    
+    public void doFormLogin(String uri, String userfield, String userid, String passfield, String password) {
+      try {
+        HttpPost httpost = new HttpPost(uri);
+        List <NameValuePair> nvps = new ArrayList <NameValuePair>();
+        nvps.add(new BasicNameValuePair(userfield, userid));
+        nvps.add(new BasicNameValuePair(passfield, password));
+        httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
+        HttpResponse response = getClient().execute(httpost,localContext);
+        HttpEntity entity = response.getEntity();
+        EntityUtils.consume(entity);
+      } catch (Throwable t) {
+        throw new RuntimeException(t);
+      }
+    }
+}

Propchange: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/Session.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/common/pom.xml
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/pom.xml?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/pom.xml (added)
+++ abdera/abdera2/common/pom.xml Tue Sep 20 15:56:46 2011
@@ -0,0 +1,81 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" 
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.abdera2</groupId>
+    <artifactId>abdera2</artifactId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+   
+  <groupId>org.apache.abdera2</groupId>
+  <artifactId>abdera2-common</artifactId>
+  
+  <packaging>bundle</packaging>
+  
+  <name>Abdera2 Common Library</name>
+  <version>2.0-SNAPSHOT</version>  
+  <description>Abdera2 Common Code Library.</description>
+  <url>http://abdera.apache.org</url>
+   
+  <properties>
+    <topDir>${basedir}/..</topDir>
+    <!--
+    <abdera.osgi.default.exports>
+      org.apache.abdera2.common.*
+    </abdera.osgi.default.exports>
+    <abdera.osgi.default.imports>
+      org.apache.commons.codec*;version="[1.5,2)",
+      *
+    </abdera.osgi.default.imports>
+    -->
+  </properties>
+  
+  
+  <dependencies>    
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-activation_1.1_spec</artifactId>
+      <version>1.1</version>  
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>javax</groupId>
+      <artifactId>javaee-web-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>com.ibm.icu</groupId>
+      <artifactId>icu4j</artifactId>
+    </dependency>
+
+  </dependencies>
+</project>

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

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Constants.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Constants.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Constants.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Constants.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common;
+
+import javax.xml.namespace.QName;
+
+public interface Constants {
+
+    public static final String PREFIX = "";
+    public static final String APP_PREFIX = "";
+    public static final String CONTROL_PREFIX = "";
+
+    public static final String JSON_MEDIA_TYPE = "application/json";
+    public static final String ATOM_MEDIA_TYPE = "application/atom+xml";
+    public static final String FEED_MEDIA_TYPE = ATOM_MEDIA_TYPE + ";type=feed";
+    public static final String ENTRY_MEDIA_TYPE = ATOM_MEDIA_TYPE + ";type=entry";
+    public static final String APP_MEDIA_TYPE = "application/atomsvc+xml";
+    public static final String XML_MEDIA_TYPE = "application/xml";
+    public static final String CAT_MEDIA_TYPE = "application/atomcat+xml";
+    public static final String MULTIPART_RELATED_TYPE = "Multipart/Related";
+
+    public static final String ATOM_NS = "http://www.w3.org/2005/Atom";
+    public static final String APP_NS = "http://www.w3.org/2007/app";
+
+    /** @deprecated Use Constants.APP_NS instead **/
+    public static final String APP_NS_PRE_RFC = "http://purl.org/atom/app#";
+
+    /** @deprecated **/
+    public static final String CONTROL_NS = "http://example.net/appns/";
+    public static final String XML_NS = "http://www.w3.org/XML/1998/namespace";
+    public static final String XHTML_NS = "http://www.w3.org/1999/xhtml";
+
+    public static final String LN_ACCEPT = "accept";
+    public static final String LN_CLASS = "class";
+    public static final String LN_DIV = "div";
+    public static final String LN_FEED = "feed";
+    public static final String LN_ENTRY = "entry";
+    public static final String LN_SERVICE = "service";
+    public static final String LN_AUTHOR = "author";
+    public static final String LN_CATEGORY = "category";
+    public static final String LN_CONTENT = "content";
+    public static final String LN_CONTRIBUTOR = "contributor";
+    public static final String LN_GENERATOR = "generator";
+    public static final String LN_ICON = "icon";
+    public static final String LN_ID = "id";
+    public static final String LN_LOGO = "logo";
+    public static final String LN_LINK = "link";
+    public static final String LN_PUBLISHED = "published";
+    public static final String LN_RIGHTS = "rights";
+    public static final String LN_SOURCE = "source";
+    public static final String LN_SUBTITLE = "subtitle";
+    public static final String LN_SUMMARY = "summary";
+    public static final String LN_TITLE = "title";
+    public static final String LN_UPDATED = "updated";
+    public static final String LN_EDITED = "edited";
+    public static final String LN_TERM = "term";
+    public static final String LN_SCHEME = "scheme";
+    public static final String LN_LABEL = "label";
+    public static final String LN_HREF = "href";
+    public static final String LN_LANG = "lang";
+    public static final String LN_BASE = "base";
+    public static final String LN_SPACE = "space";
+    public static final String LN_URI = "uri";
+    public static final String LN_VERSION = "version";
+    public static final String LN_REL = "rel";
+    public static final String LN_TYPE = "type";
+    public static final String LN_HREFLANG = "hreflang";
+    public static final String LN_LENGTH = "length";
+    public static final String LN_NAME = "name";
+    public static final String LN_EMAIL = "email";
+    public static final String LN_WORKSPACE = "workspace";
+    public static final String LN_SRC = "src";
+    public static final String LN_COLLECTION = "collection";
+    public static final String LN_CONTROL = "control";
+    public static final String LN_DRAFT = "draft";
+    public static final String LN_CATEGORIES = "categories";
+    public static final String LN_FIXED = "fixed";
+    public static final String LN_ALTERNATE = "alternate";
+    public static final String LN_ALTERNATE_MULTIPART_RELATED = "multipart-related";
+
+    public static final QName DIV = new QName(XHTML_NS, LN_DIV, "");
+
+    public static final QName CONTROL = new QName(APP_NS, LN_CONTROL, "app");
+    public static final QName DRAFT = new QName(APP_NS, LN_DRAFT, "app");
+    public static final QName CATEGORIES = new QName(APP_NS, LN_CATEGORIES, APP_PREFIX);
+    public static final QName SERVICE = new QName(APP_NS, LN_SERVICE, APP_PREFIX);
+    public static final QName EDITED = new QName(APP_NS, LN_EDITED, "app");
+    public static final QName ACCEPT = new QName(APP_NS, LN_ACCEPT, APP_PREFIX);
+    public static final QName WORKSPACE = new QName(APP_NS, LN_WORKSPACE, APP_PREFIX);
+    public static final QName COLLECTION = new QName(APP_NS, LN_COLLECTION, APP_PREFIX);
+
+    /** @deprecated **/
+    public static final QName PRE_RFC_CONTROL = new QName(APP_NS_PRE_RFC, LN_CONTROL, "app");
+    /** @deprecated **/
+    public static final QName PRE_RFC_DRAFT = new QName(APP_NS_PRE_RFC, LN_DRAFT, "app");
+    /** @deprecated **/
+    public static final QName PRE_RFC_CATEGORIES = new QName(APP_NS_PRE_RFC, LN_CATEGORIES, APP_PREFIX);
+    /** @deprecated **/
+    public static final QName PRE_RFC_SERVICE = new QName(APP_NS_PRE_RFC, LN_SERVICE, APP_PREFIX);
+    /** @deprecated **/
+    public static final QName PRE_RFC_EDITED = new QName(APP_NS_PRE_RFC, LN_EDITED, "app");
+    /** @deprecated **/
+    public static final QName PRE_RFC_ACCEPT = new QName(APP_NS_PRE_RFC, LN_ACCEPT, APP_PREFIX);
+    /** @deprecated **/
+    public static final QName PRE_RFC_WORKSPACE = new QName(APP_NS_PRE_RFC, LN_WORKSPACE, APP_PREFIX);
+    /** @deprecated **/
+    public static final QName PRE_RFC_COLLECTION = new QName(APP_NS_PRE_RFC, LN_COLLECTION, APP_PREFIX);
+
+    public static final QName FEED = new QName(ATOM_NS, LN_FEED, PREFIX);
+    public static final QName AUTHOR = new QName(ATOM_NS, LN_AUTHOR, PREFIX);
+    public static final QName CATEGORY = new QName(ATOM_NS, LN_CATEGORY, PREFIX);
+    public static final QName CONTENT = new QName(ATOM_NS, LN_CONTENT, PREFIX);
+    public static final QName CONTRIBUTOR = new QName(ATOM_NS, LN_CONTRIBUTOR, PREFIX);
+    public static final QName GENERATOR = new QName(ATOM_NS, LN_GENERATOR, PREFIX);
+    public static final QName ICON = new QName(ATOM_NS, LN_ICON, PREFIX);
+    public static final QName ID = new QName(ATOM_NS, LN_ID, PREFIX);
+    public static final QName LOGO = new QName(ATOM_NS, LN_LOGO, PREFIX);
+    public static final QName LINK = new QName(ATOM_NS, LN_LINK, PREFIX);
+    public static final QName PUBLISHED = new QName(ATOM_NS, LN_PUBLISHED, PREFIX);
+    public static final QName RIGHTS = new QName(ATOM_NS, LN_RIGHTS, PREFIX);
+    public static final QName SOURCE = new QName(ATOM_NS, LN_SOURCE, PREFIX);
+    public static final QName SUBTITLE = new QName(ATOM_NS, LN_SUBTITLE, PREFIX);
+    public static final QName SUMMARY = new QName(ATOM_NS, LN_SUMMARY, PREFIX);
+    public static final QName TITLE = new QName(ATOM_NS, LN_TITLE, PREFIX);
+    public static final QName PREFIXED_TITLE = new QName(ATOM_NS, LN_TITLE, "atom");
+    public static final QName UPDATED = new QName(ATOM_NS, LN_UPDATED, PREFIX);
+    public static final QName ENTRY = new QName(ATOM_NS, LN_ENTRY, PREFIX);
+    public static final QName TERM = new QName(LN_TERM);
+    public static final QName SCHEME = new QName(LN_SCHEME);
+    public static final QName FIXED = new QName(LN_FIXED);
+    public static final QName LABEL = new QName(LN_LABEL);
+    public static final QName ATITLE = new QName(LN_TITLE);
+    public static final QName HREF = new QName(LN_HREF);
+    public static final QName LANG = new QName(XML_NS, LN_LANG, "xml");
+    public static final QName BASE = new QName(XML_NS, LN_BASE, "xml");
+    public static final QName SPACE = new QName(XML_NS, LN_SPACE, "xml");
+    public static final QName AURI = new QName(LN_URI);
+    public static final QName VERSION = new QName(LN_VERSION);
+    public static final QName REL = new QName(LN_REL);
+    public static final QName TYPE = new QName(LN_TYPE);
+    public static final QName HREFLANG = new QName(LN_HREFLANG);
+    public static final QName LENGTH = new QName(LN_LENGTH);
+    public static final QName NAME = new QName(ATOM_NS, LN_NAME, PREFIX);
+    public static final QName EMAIL = new QName(ATOM_NS, LN_EMAIL, PREFIX);
+    public static final QName URI = new QName(ATOM_NS, LN_URI, PREFIX);
+    public static final QName SRC = new QName(LN_SRC);
+    public static final QName AID = new QName(LN_ID);
+    public static final QName CLASS = new QName(LN_CLASS);
+    public static final QName ALTERNATE = new QName(LN_ALTERNATE);
+
+    public static final String TEXT = "text";
+    public static final String HTML = "html";
+    public static final String XHTML = "xhtml";
+    public static final String XML = "xml";
+    public static final String YES = "yes";
+    public static final String NO = "no";
+
+}

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

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Discover.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Discover.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,339 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.abdera2.common.anno.AnnoUtil;
+import org.apache.abdera2.common.misc.MultiIterator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+@SuppressWarnings("unchecked")
+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(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) {
+      try {
+        T instance = null, first = null;
+        Iterable<T> items = 
+          locate(_class, loader, args);
+        Iterator<T> is = items.iterator();
+        if (defaultImpl == null)
+          defaultImpl = AnnoUtil.getDefaultImplementation(_class);
+        while (instance == null && is.hasNext()) {
+          T i = is.next();
+          if (defaultImpl != null && defaultImpl.equals(i.getClass().getName())) {
+            instance = i; 
+            break;
+          } else if (first == null)
+            first = i;
+        }
+        instance = instance != null ? instance : first;
+        return instance != null ? 
+          instance :
+          (T)load(loader, defaultImpl, false, args);
+      } catch (Throwable t) {
+          throw new RuntimeException(t);
+      }      
+    }
+    
+    public static <T> T locate(String id, String defaultImpl, ClassLoader loader, Object... args) {
+        try {
+            T instance = null;
+            Iterable<T> items = 
+              locate(id, loader, args);
+            for (T i : items) {
+                instance = i;
+                break;
+            }
+            return instance != null ? 
+              instance :
+              (T)load(loader, defaultImpl, false, args);
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    private static ClassLoader getLoader() {
+        return Thread.currentThread().getContextClassLoader();
+    }
+
+    public static <T> Iterable<T> locate(Class<T> _class, ClassLoader cl, Object... args) {
+        return locate(_class, false, cl, args);
+    }
+    
+    public static <T> Iterable<T> locate(String id, 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(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, 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(String id, boolean classesonly, Object... args) {
+        return locate(new DefaultLoader<T>(id, classesonly, args));
+    }
+
+    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);
+            }
+        } catch (Throwable t) {
+            log.error(t);
+        }
+        return impls;
+    }
+
+    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();
+            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) {
+          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 new MultiIterator<T>(list);
+            } catch (Throwable t) {
+                throw new RuntimeException(t);
+            }
+        }
+
+        public Iterator<T> 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 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);
+            }
+        }
+    }
+
+    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();
+            }
+        }
+    }
+
+    private static <T> Class<T> getClass(ClassLoader loader, String spec) {
+        Class<T> c = null;
+        try {
+            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);
+            }
+        }
+        return c;
+    }
+
+    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) {
+            super(cl);
+            this.args = args;
+            this.classesonly = classesonly;
+            try {
+                InputStreamReader reader = new InputStreamReader(in, "UTF-8");
+                buf = new BufferedReader(reader);
+                line = readNext();
+            } catch (Throwable t) {
+                throw new RuntimeException(t);
+            }
+        }
+
+        public boolean hasNext() {
+            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);
+            }
+        }
+
+        protected String read() {
+            String val = line;
+            line = readNext();
+            return val;
+        }
+    }
+
+    public static abstract class LoaderIterator<T> implements Iterator<T> {
+        protected final ClassLoader cl;
+
+        protected LoaderIterator(ClassLoader cl) {
+            this.cl = cl;
+        }
+
+        public void remove() {
+        }
+    }
+
+    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));
+        if (url == null)
+            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));
+        }
+        return url;
+    }
+
+    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;
+    }
+
+    public static InputStream locateResourceAsStream(String resourceName, ClassLoader loader, Class<?> callingClass) {
+        URL url = locateResource(resourceName, loader, callingClass);
+        try {
+            return (url != null) ? url.openStream() : null;
+        } catch (IOException e) {
+            return null;
+        }
+    }
+}

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

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Localizer.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/Localizer.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Wraps ResourceBundle with a couple of additional, useful methods. Used for l10n
+ */
+public final class Localizer {
+
+    private static Localizer instance = null;
+
+    public static synchronized Localizer getInstance() {
+        if (instance == null)
+            instance = new Localizer();
+        return instance;
+    }
+
+    public static synchronized void setInstance(Localizer localizer) {
+        Localizer.instance = localizer;
+    }
+
+    public static String get(String key) {
+        return getInstance().getValue(key);
+    }
+
+    public static String get(String key, String defaultValue) {
+        return getInstance().getValue(key, defaultValue);
+    }
+
+    public static String sprintf(String key, Object... args) {
+        return getInstance().sprintfValue(key, args);
+    }
+
+    private static final String DEFAULT_BUNDLE = "abderamessages";
+
+    private final Locale locale;
+    private final ResourceBundle bundle;
+
+    public Localizer() {
+        this(Locale.getDefault(), Thread.currentThread().getContextClassLoader());
+    }
+
+    public Localizer(Locale locale, 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.bundle = bundle;
+        this.locale = locale;
+    }
+
+    private static ResourceBundle initResourceBundle(String bundle, Locale locale, ClassLoader loader) {
+        try {
+            return ResourceBundle.getBundle(bundle, locale, loader);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public Locale getLocale() {
+        return locale;
+    }
+
+    public String getValue(String key) {
+        try {
+            return bundle.getString(key);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public String getValue(String key, String defaultValue) {
+        String value = getValue(key);
+        return value != null ? value : defaultValue;
+    }
+
+    /**
+     * Use the JDK 1.5 sprintf style Formatter
+     */
+    public String sprintfValue(String key, Object... args) {
+        String value = getValue(key);
+        return value != null ? String.format(locale, value, args) : null;
+    }
+}

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

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/AnnoUtil.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/AnnoUtil.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.anno;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+
+public 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.
+   */
+  public static String getName(Object item) {
+    if (item == null) return null;
+    Class<?> _class = 
+      item instanceof Class ? (Class<?>)item :
+      item.getClass();
+    return _class.isAnnotationPresent(Name.class) ?
+      _class.getAnnotation(Name.class).value() : 
+      _class.getSimpleName().toLowerCase();
+  }
+
+  /**
+   * Retrieve the default implementation for the specified Class.
+   */
+  public static String getDefaultImplementation(Class<?> _class) {
+    String _default = null;
+    if (_class.isAnnotationPresent(DefaultImplementation.class)) {
+      DefaultImplementation di = 
+        _class.getAnnotation(DefaultImplementation.class);
+      _default = di.value();
+    }
+    return _default;
+  }
+
+  /**
+   * Retrieve the Version annotation from the specified item
+   */
+  public static Version getVersion(Object item) {
+    if (item == null) return null;
+    Class<?> _class = 
+      item instanceof Class ? (Class<?>)item :
+      item.getClass();
+    return _class.isAnnotationPresent(Version.class) ?
+      _class.getAnnotation(Version.class) :
+      null;
+  }
+
+  /**
+   * Returns the Namespace URIs handled by this Extension Factory
+   * 
+   * @return A List of Namespace URIs Supported by this Extension
+   */
+  public static Set<String> getNamespaces(Object obj) {
+    if (obj == null) return Collections.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())
+        ns.add(n);
+    }
+    return ns;
+  }
+
+  /**
+   * Returns true if the given object "handles" the given namespace based
+   * on values specified using the Namespace annotation
+   */
+  public static boolean handlesNamespace(String namespace, Object obj) {
+    Set<String> set = getNamespaces(obj);
+    return set.contains(namespace);
+  }
+  
+  /**
+   * Retrieve a javax.xml.namespace.QName from a class using the QName annotation.
+   */
+  public static QName qNameFromAnno(org.apache.abdera2.common.anno.QName impl) {
+    QName result = null;
+    String name = impl.value();
+      String ns = impl.ns();
+      String pfx = impl.pfx();
+      if (pfx != null && pfx.length() > 0) {
+        result = new QName(ns,name,pfx);
+      } else if (ns != null && ns.length() > 0) {
+        result = new QName(ns,name);
+      } else if (name != null && name.length() > 0) {
+        result = new QName(name);
+      };
+    return result;
+  }
+  
+  /**
+   * Retrieve a javax.xml.namespace.QName from an instance object using the 
+   * QName annotation
+   */
+  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)) {
+      return qNameFromAnno(_class.getAnnotation(org.apache.abdera2.common.anno.QName.class));
+    }
+    return null;
+  }
+}

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

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Context.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Context.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,13 @@
+package org.apache.abdera2.common.anno;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target( {TYPE})
+public @interface Context {
+  Param[] value();
+}

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

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/DefaultImplementation.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/DefaultImplementation.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/DefaultImplementation.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/DefaultImplementation.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.anno;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target( {TYPE})
+public @interface DefaultImplementation {
+  String value();
+}

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

Added: 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=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Name.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Name.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.anno;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target( {TYPE,FIELD,METHOD})
+@Inherited
+public @interface Name {
+
+  String value();
+  
+}

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

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Namespace.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Namespace.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Namespace.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Namespace.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.anno;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target( {TYPE})
+public @interface Namespace {
+  String[] value();
+}

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

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Param.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Param.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Param.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/Param.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,14 @@
+package org.apache.abdera2.common.anno;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target( {TYPE})
+public @interface Param {
+  String name();
+  String value();
+}

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

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/QName.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/QName.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/QName.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/anno/QName.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.common.anno;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target( {TYPE})
+@Inherited
+public @interface QName {
+  String value();
+  String ns() default "";
+  String pfx() default "";
+}

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



Mime
View raw message