abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r616050 [1/3] - in /incubator/abdera/java/trunk/extensions/converters: ./ src/main/java/org/apache/abdera/converter/ src/main/java/org/apache/abdera/ext/ src/main/java/org/apache/abdera/ext/serializer/ src/main/java/org/apache/abdera/ext/se...
Date Mon, 28 Jan 2008 21:26:05 GMT
Author: jmsnell
Date: Mon Jan 28 13:26:00 2008
New Revision: 616050

URL: http://svn.apache.org/viewvc?rev=616050&view=rev
Log:
Reworking the annotation-based converter framework around the StreamWriter interface.
This includes an ObjectResponseContext class that will allow a conforming java-bean to be returned by a server impl and automatically serialized into an Atom document.

This is highly experimental and needs to be fully debugged. Expect changes

Added:
    incubator/abdera/java/trunk/extensions/converters/pom.xml
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractConventions.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractSerializationContext.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/BaseSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ConventionSerializationContext.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Conventions.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultConventions.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultSerializationContext.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectContext.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectResponseContext.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationContext.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationException.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Serializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializerProvider.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Accept.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Attribute.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Author.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/BaseURI.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Categories.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Category.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Collection.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Content.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Contributor.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Control.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Convention.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/DateTime.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Draft.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Edited.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Email.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/EntityTag.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Entry.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Extension.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Feed.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Generator.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/HrefLanguage.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/ID.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/IRI.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Icon.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Label.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Language.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/LastModified.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Length.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Link.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Logo.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/MediaType.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Person.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Published.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Rel.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Rights.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Scheme.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Serializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Service.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Source.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Src.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Subtitle.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Summary.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Text.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Title.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/URI.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Updated.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Value.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Version.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Workspace.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategoriesSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategorySerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CollectionSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ContentSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ControlSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/DateTimeSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ElementSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/EntrySerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ExtensionSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FOMSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FeedSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/GeneratorSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/IRISerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/LinkSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/PersonSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ServiceSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SimpleElementSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SourceSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/TextSerializer.java
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/WorkspaceSerializer.java
Removed:
    incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/

Added: incubator/abdera/java/trunk/extensions/converters/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/pom.xml?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/pom.xml (added)
+++ incubator/abdera/java/trunk/extensions/converters/pom.xml Mon Jan 28 13:26:00 2008
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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. -->
+<project 
+  xmlns="http://maven.apache.org/POM/4.0.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.abdera</groupId>
+    <artifactId>abdera</artifactId>
+    <version>0.4.0-incubating-SNAPSHOT</version>
+  </parent>  
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>abdera-extensions-serializer</artifactId>
+  <packaging>jar</packaging>
+  <name>Abdera Extensions - Serializer</name>
+  <version>0.4.0-incubating-SNAPSHOT</version>
+  <description>Atom Specification Extensions - Serializer</description>
+  <inceptionYear>2006</inceptionYear>
+  <url>http://incubator.apache.org/abdera</url>
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/abdera/java/trunk/extensions/serializer</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/abdera/java/trunk/extensions/serializer</developerConnection>
+    <url>http://svn.apache.org/repos/asf/incubator/abdera/java/trunk/extensions/serializer</url>
+  </scm>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-core</artifactId>
+      <version>0.4.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>    
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-parser</artifactId>
+      <version>0.4.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>   
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-protocol</artifactId>
+      <version>0.4.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>  
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-server</artifactId>
+      <version>0.4.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>  
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.woodstox</groupId>
+      <artifactId>wstx-asl</artifactId>
+    </dependency> 
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractConventions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractConventions.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractConventions.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractConventions.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,129 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Member;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.apache.abdera.ext.serializer.annotation.Convention;
+
+public abstract class AbstractConventions
+    implements Conventions, 
+               Cloneable,
+               Serializable {
+  
+  private final Map<Class<? extends Annotation>,Pattern> conventions = 
+    new HashMap<Class<? extends Annotation>,Pattern>();
+  private final boolean isCaseSensitive;
+  
+  protected AbstractConventions() {
+    this(false);
+  }
+  
+  protected AbstractConventions(boolean isCaseSensitive) {
+    this.isCaseSensitive = isCaseSensitive;
+  }
+
+  public Iterator<Class<? extends Annotation>> iterator() {
+    return conventions.keySet().iterator();
+  }
+  
+  public void setConvention(
+    String pattern,
+    Class<? extends Annotation> annotationType) {
+      Pattern regex = 
+        isCaseSensitive ? 
+          Pattern.compile(pattern) : 
+          Pattern.compile(pattern,Pattern.CASE_INSENSITIVE);
+        conventions.put(annotationType, regex);
+  }
+  
+  public void setConvention(
+    Class<? extends Annotation> annotationType) {
+      Convention conv = annotationType.getAnnotation(Convention.class);
+      if (conv == null) 
+        throw new IllegalArgumentException(
+          "No Convention Annotation [" + annotationType + "]");
+      setConvention(conv.value(),annotationType);
+  }
+  
+  public Class<? extends Annotation> matchConvention(
+    AccessibleObject accessor) {
+      return matchConvention(accessor, null);
+  }
+
+  public Class<? extends Annotation> matchConvention(
+    AccessibleObject accessor, 
+    Class<? extends Annotation> expect) {
+      if (accessor == null) return null;
+      String name = ((Member)accessor).getName();
+      for (Map.Entry<Class<? extends Annotation>, Pattern> entry : conventions.entrySet()) {
+        if (entry.getValue().matcher(name).matches() && 
+           (expect == null || expect == entry.getKey()))
+          return entry.getKey();
+      }
+      return null;
+  }
+  
+  public boolean isMatch(
+    AccessibleObject accessor, 
+    Class<? extends Annotation> expect) {
+      return matchConvention(accessor,expect) != null;
+  }
+
+  @Override
+  public int hashCode() {
+    final int PRIME = 31;
+    int result = 1;
+    result = PRIME * result + ((conventions == null) ? 0 : conventions.hashCode());
+    result = PRIME * result + (isCaseSensitive ? 1231 : 1237);
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) return true;
+    if (obj == null) return false;
+    if (getClass() != obj.getClass()) return false;
+    final AbstractConventions other = (AbstractConventions) obj;
+    if (conventions == null) {
+      if (other.conventions != null) return false;
+    } else if (!conventions.equals(other.conventions)) return false;
+    if (isCaseSensitive != other.isCaseSensitive) return false;
+    return true;
+  }
+ 
+  public Conventions clone() {
+    try {
+      return (Conventions)super.clone();
+    } catch (CloneNotSupportedException e) {
+      return copy();
+    }
+  }
+  
+  protected Conventions copy() {
+    throw new SerializationException(
+      new CloneNotSupportedException());
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractSerializationContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractSerializationContext.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractSerializationContext.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/AbstractSerializationContext.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,170 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.ext.serializer.impl.FOMSerializer;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.writer.StreamWriter;
+
+@SuppressWarnings("unchecked")
+public abstract class AbstractSerializationContext
+  implements SerializationContext {
+
+  private final Abdera abdera;
+  private final StreamWriter streamWriter; 
+  private final Map<Class,Serializer> serializers = 
+    new HashMap<Class,Serializer>();
+  
+  protected AbstractSerializationContext(
+    StreamWriter streamWriter) {
+      this(new Abdera(), streamWriter);
+  }
+  
+  protected AbstractSerializationContext(
+    Abdera abdera,
+    StreamWriter streamWriter) {
+      this.abdera = abdera;
+      this.streamWriter = streamWriter;
+      setSerializer(Element.class, new FOMSerializer());
+  }
+  
+  public StreamWriter getStreamWriter() {
+    return this.streamWriter;
+  }
+  
+  public Abdera getAbdera() {
+    return abdera;
+  }
+  
+  public Serializer getSerializer(ObjectContext objectContext) {
+    try {
+      Class type = objectContext.getObjectType();
+      Serializer serializer = serializers.get(type);
+      if (serializer == null) serializer = objectContext.getSerializer();
+      if (serializer == null) {
+        for (Annotation annotation : objectContext.getAnnotations()) {
+          serializer = serializers.get(annotation.annotationType());
+          if (serializer != null) return serializer;
+        }
+      }
+      if (serializer == null && !type.isAnnotation()) {
+        for (Class knownType : serializers.keySet()) {
+          if (!knownType.isAnnotation() && 
+              knownType.isAssignableFrom(type)) {
+            return serializers.get(knownType);
+          }
+        }
+      }
+      return serializer;
+    } catch (Throwable t) {
+      throw new SerializationException(t);
+    }
+  }
+
+  public boolean hasSerializer(ObjectContext objectContext) {
+    return getSerializer(objectContext) != null;
+  }
+  
+  public boolean hasSerializer(Object object) {
+    return hasSerializer(new ObjectContext(object));
+  }
+  
+  public boolean hasSerializer(
+    Object object, 
+    Object parent, 
+    AccessibleObject accessor) {
+      return hasSerializer(new ObjectContext(object,parent,accessor));
+  }
+  
+  public boolean hasSerializer(Class<?> type) {
+    if (serializers.containsKey(type)) return true;
+    if (!type.isAnnotation()) {
+      for (Class<?> t : serializers.keySet()) {
+        if (!t.isAnnotation() && 
+            t.isAssignableFrom(type)) return true;
+      }
+    }
+    return false;
+  }
+  
+  public boolean hasSerializer(AccessibleObject accessor) {
+    Class<? extends Object> returnType = getReturnType(accessor);
+    org.apache.abdera.ext.serializer.annotation.Serializer serializer = 
+      accessor.getAnnotation(org.apache.abdera.ext.serializer.annotation.Serializer.class);
+    if (serializer != null && hasSerializer(serializer.value())) return true;
+    if (returnType != null && hasSerializer(returnType)) return true;
+    return false;
+  }
+
+  public void setSerializer(Class type, Serializer Serializer) {
+    serializers.put(type, Serializer);
+  }
+
+  public void serialize(Object object) {
+    serialize(object,new ObjectContext(object));
+  }
+
+  public void serialize(Object object, ObjectContext objectContext) {
+    if (objectContext == null) objectContext = new ObjectContext(object);
+    Serializer serializer = getSerializer(objectContext);
+    if (serializer != null)
+      serialize(object,objectContext,serializer);
+    else 
+      throw new SerializationException(
+        "No Serializer available for " + 
+        objectContext.getObjectType());
+  }
+
+  public void serialize(Object object, Serializer serializer) {
+    serialize(object,new ObjectContext(object),serializer);
+  }
+
+  public void serialize(
+    Object object, 
+    ObjectContext objectContext, 
+    Serializer serializer) {
+      if (objectContext == null) objectContext = new ObjectContext(object);
+      Serializer overrideSerializer = getSerializer(objectContext);
+      if (overrideSerializer != null) serializer = overrideSerializer;
+      if (serializer != null) {
+        serializer.serialize(object, objectContext, this);
+      } else {
+        throw new SerializationException(
+          "No Serializer available for " + 
+          objectContext.getObjectType());
+      }
+  }
+  
+  public static Class<? extends Object> getReturnType(
+    AccessibleObject accessor) {
+      if (accessor instanceof Field)
+        return ((Field)accessor).getType();
+      else if (accessor instanceof Method) 
+        return ((Method)accessor).getReturnType();
+      else return null;
+  }
+
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/BaseSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/BaseSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/BaseSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/BaseSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,365 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.annotation.Attribute;
+import org.apache.abdera.ext.serializer.annotation.BaseURI;
+import org.apache.abdera.ext.serializer.annotation.Extension;
+import org.apache.abdera.ext.serializer.annotation.Language;
+import org.apache.abdera.ext.serializer.annotation.Value;
+import org.apache.abdera.ext.serializer.impl.ExtensionSerializer;
+import org.apache.abdera.ext.serializer.impl.SimpleElementSerializer;
+import org.apache.abdera.i18n.rfc4646.Lang;
+import org.apache.abdera.writer.StreamWriter;
+
+@SuppressWarnings("unchecked")
+public abstract class BaseSerializer 
+  extends Serializer {
+  
+  public static final String DEFAULT = "##default";
+
+  protected abstract void init(
+    Object source, 
+    ObjectContext objectContext, 
+    SerializationContext context,
+    Conventions conventions);
+  
+  protected abstract void finish(
+    Object source, 
+    ObjectContext objectContext, 
+    SerializationContext context,
+    Conventions conventions);
+
+  protected void process(
+    Object source,
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+  }
+  
+  public void serialize(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context) {
+    Conventions conventions = 
+      ((ConventionSerializationContext)context)
+        .getConventions();
+      init(
+        source,
+        objectContext, 
+        context,
+        conventions);
+      process(source, objectContext, context, conventions);
+      finish(
+        source, 
+        objectContext, 
+        context,
+        conventions);    
+  }
+  
+  protected void writeTextValue(
+    Object source,
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      AccessibleObject accessor = 
+        objectContext.getAccessor(
+          Value.class, 
+          conventions);
+      Object value = null;
+      if (accessor != null) {
+        value = eval(accessor, source);
+      }
+      context.getStreamWriter()
+        .writeElementText(
+          value != null ?
+            toString(value) :
+            toString(source));
+  }
+    
+  protected void writeExtensions(
+    Object source,
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      AccessibleObject[] accessors = objectContext.getAccessors(Extension.class, conventions);
+      for (AccessibleObject accessor : accessors) {
+        Object value = eval(accessor,source);
+        ObjectContext valueContext = new ObjectContext(value,source,accessor);
+        Extension extension = valueContext.getAnnotation(Extension.class);
+        boolean simple = extension != null ? extension.simple() : false;
+        Serializer ser = context.getSerializer(valueContext);
+        if (ser == null) {
+          if (simple) {
+            QName qname = getQName(accessor);
+            ser = new SimpleElementSerializer(qname);
+          } else {
+            ser = context.getSerializer(valueContext);
+            if (ser == null) {
+              QName qname = getQName(accessor);
+              ser = new ExtensionSerializer(qname);
+            }
+          }
+        }
+        ser.serialize(value, valueContext, context);
+      }
+  }
+  
+  protected void writeAttributes(
+    Object source,
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      writeCommon(source, objectContext, context, conventions);
+      StreamWriter sw = context.getStreamWriter();
+      AccessibleObject[] accessors = objectContext.getAccessors(Attribute.class, conventions);
+      for (AccessibleObject accessor : accessors) {
+        QName qname = getQName(accessor);
+        Object value = eval(accessor, source);
+        if (value != null) 
+          sw.writeAttribute(qname, toString(value));
+      }
+  }
+  
+  protected boolean writeElement(
+    Class<? extends Annotation> annotation,
+    Serializer serializer,
+    Object source,
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      AccessibleObject accessor = objectContext.getAccessor(annotation, conventions);
+      if (accessor != null) {
+        Object value = eval(accessor, source);
+        ObjectContext valueContext = new ObjectContext(value,source,accessor);
+        serializer.serialize(value, valueContext, context);
+        return true;
+      }
+      return false;
+  }
+  
+  protected void writeElements(
+    Class<? extends Annotation> annotation,
+    Serializer serializer,
+    Object source,
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      AccessibleObject[] accessors = objectContext.getAccessors(annotation, conventions);
+      for (AccessibleObject accessor : accessors) {
+        if (accessor != null) {
+          Object value = eval(accessor, source);
+          Object[] values = toArray(value);
+          for (Object val : values) {
+            ObjectContext valueContext = new ObjectContext(val,source,accessor);
+            serializer.serialize(val, valueContext, context);
+          }
+        }
+      }
+  }  
+  
+  public static Object eval(AccessibleObject accessor, Object parent) {
+    try {
+      if (accessor instanceof Field) 
+        return ((Field)accessor).get(parent);
+      else if (accessor instanceof Method) 
+        return ((Method)accessor).invoke(parent, new Object[0]);
+      else return null;
+    } catch (Throwable t) {
+      throw new SerializationException(t);
+    }
+  }
+  
+  protected boolean hasAnnotation(
+    AnnotatedElement item, 
+    Class<? extends Annotation> annotation) {
+      return item.isAnnotationPresent(annotation);
+  }
+  
+  protected void writeElement(StreamWriter sw, QName qname, String value) {
+    sw.startElement(qname)
+      .writeElementText(value)
+      .endElement();
+  }
+  
+  public static String toString(Object value) {
+    if (value == null) return null;
+    Object[] values = toArray(value);
+    StringBuilder buf = new StringBuilder();
+    for (int n= 0; n < values.length; n++) {
+      if (n > 0) buf.append(", ");
+      buf.append(values[n].toString());
+    }
+    return buf.toString();
+  }
+  
+  public static Object[] toArray(Object value) {
+    if (value == null) return new Object[0];
+    if (value.getClass().isArray()) {
+      return (Object[])value;
+    } else if (value instanceof Collection) { 
+      return ((Collection)value).toArray();
+    } else if (value instanceof Map) {
+      return ((Map)value).values().toArray();
+    } else if (value instanceof Dictionary) {
+      List<Object> list = new ArrayList<Object>();
+      Enumeration e = ((Dictionary)value).elements();
+      while(e.hasMoreElements()) list.add(e.nextElement());
+      return list.toArray();
+    } else if (value instanceof Iterator) { 
+      List<Object> list = new ArrayList<Object>();
+      Iterator i = (Iterator) value;
+      while(i.hasNext()) list.add(i.next());
+      return list.toArray();
+    } else if (value instanceof Enumeration) {
+      List<Object> list = new ArrayList<Object>();
+      Enumeration e = (Enumeration) value;
+      while(e.hasMoreElements()) list.add(e.nextElement());
+      return list.toArray();
+    } else if (value instanceof Iterable) {
+      List<Object> list = new ArrayList<Object>();
+      Iterable v = (Iterable) value;
+      Iterator i = v.iterator();
+      while(i.hasNext()) list.add(i.next());
+      return list.toArray();
+    } else {
+      return new Object[] {value};
+    }
+  }
+  
+  protected static boolean isUndefined(String value) {
+    return value == null || DEFAULT.equals(value);
+  }
+  
+  protected static QName getQName(AccessibleObject accessor) {
+    Extension ext = accessor.getAnnotation(Extension.class);
+    if (ext != null) return getQName(ext);
+    Attribute attr = accessor.getAnnotation(Attribute.class);
+    if (attr != null) return getQName(attr);
+    return new QName(
+      accessor instanceof Method ?
+        ((Method)accessor).getName() :
+        ((Field)accessor).getName());
+  }
+  
+  protected static QName getQName(
+    Extension extension) {
+    QName qname = null;
+    if (extension != null) {
+      if (isUndefined(extension.prefix()) && 
+          isUndefined(extension.ns()) && 
+          isUndefined(extension.name())) {
+        qname = new QName(
+          extension.ns(), 
+          extension.name(), 
+          extension.prefix());
+      } else if (
+          isUndefined(extension.prefix()) && 
+          !isUndefined(extension.ns()) && 
+          !isUndefined(extension.name())) {
+        qname = new QName(
+          extension.ns(), 
+          extension.name());
+      } else if (!isUndefined(extension.name())) {
+        qname = new QName(extension.name());
+      }
+    }
+    return qname;
+  }
+  
+  protected static QName getQName(
+    Attribute attribute) {
+    QName qname = null;
+    if (attribute != null) {
+      if (isUndefined(attribute.prefix()) && 
+          isUndefined(attribute.ns()) && 
+          isUndefined(attribute.name())) {
+        qname = new QName(
+          attribute.ns(), 
+          attribute.name(), 
+          attribute.prefix());
+      } else if (
+          isUndefined(attribute.prefix()) && 
+          !isUndefined(attribute.ns()) && 
+          !isUndefined(attribute.name())) {
+        qname = new QName(
+          attribute.ns(), 
+          attribute.name());
+      } else if (!isUndefined(attribute.name())) {
+        qname = new QName(attribute.name());
+      }
+    }
+    return qname;
+  }
+  
+  @SuppressWarnings("deprecation") 
+  protected void writeCommon(
+    Object source,
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      StreamWriter sw = context.getStreamWriter();
+      String lang = null;
+      AccessibleObject accessor = objectContext.getAccessor(Language.class, conventions);
+      if (accessor != null) {
+        Object value = eval(accessor, source);
+        if (value != null) {
+          if (value instanceof Lang ||
+              value instanceof org.apache.abdera.i18n.lang.Lang) {
+            lang = value.toString();
+          } else {
+            lang = toString(value);
+          }
+        }
+      }
+      if (lang == null) {
+        Language _lang = objectContext.getAnnotation(Language.class);
+        if (_lang != null && !_lang.value().equals(DEFAULT)) {
+          lang = _lang.value();
+        }
+      }
+      if (lang != null)
+        sw.writeLanguage(lang);
+      
+  
+      String base = null;
+      accessor = objectContext.getAccessor(BaseURI.class, conventions);
+      if (accessor != null) {
+        Object value = eval(accessor, source);
+        if (value != null)
+          base = toString(value);
+      }
+      if (base != null)
+        sw.writeBase(base);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ConventionSerializationContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ConventionSerializationContext.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ConventionSerializationContext.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ConventionSerializationContext.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,91 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.writer.StreamWriter;
+
+public class ConventionSerializationContext 
+  extends DefaultSerializationContext {
+
+  private static final long serialVersionUID = 7504071837124132972L;
+  
+  protected Conventions conventions;
+  
+  public ConventionSerializationContext(StreamWriter streamWriter) {
+    this(new Abdera(),streamWriter);
+  }
+
+  public ConventionSerializationContext(
+    Conventions conventions,
+    StreamWriter streamWriter) {
+      this(null,conventions,streamWriter);
+  }
+  
+  public ConventionSerializationContext(
+    Abdera abdera,
+    StreamWriter streamWriter) {
+      super(abdera,streamWriter);
+      this.conventions = new DefaultConventions();
+      initSerializers();
+  }
+  
+  public ConventionSerializationContext(
+    Abdera abdera, 
+    Conventions conventions,
+    StreamWriter streamWriter) {
+      super(abdera,streamWriter);
+      this.conventions = conventions;
+      initSerializers();
+  }
+
+  public Conventions getConventions() {
+    return conventions;
+  }
+  
+  public void setConventions(Conventions conventions) {
+    this.conventions = conventions;
+  }
+  
+  public boolean hasSerializer(AccessibleObject accessor) {
+    boolean answer = super.hasSerializer(accessor);
+    if (answer) return true;
+    Class<? extends Annotation> annotation = 
+      getConventions().matchConvention(accessor);
+    return annotation != null && hasSerializer(annotation);
+  }
+  
+  private <T>void initSerializers() {
+    for (Class<? extends Annotation> type : conventions) {
+      org.apache.abdera.ext.serializer.annotation.Serializer serializer = 
+        type.getAnnotation(org.apache.abdera.ext.serializer.annotation.Serializer.class);
+      if (serializer != null) {
+        try {
+          Serializer ser = serializer.value().newInstance();
+          this.setSerializer(type,ser);
+        } catch (Throwable t) {
+          throw new SerializationException(t);
+        }
+      }
+    }
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Conventions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Conventions.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Conventions.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Conventions.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,48 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+
+public interface Conventions
+  extends Serializable, 
+          Cloneable, 
+          Iterable<Class <? extends Annotation>>{
+  
+  void setConvention(
+    Class<? extends Annotation> annotationType);
+  
+  void setConvention(
+    String pattern, 
+    Class<? extends Annotation> annotationType);
+  
+  Class<? extends Annotation> matchConvention(
+    AccessibleObject accessor);
+  
+  Class<? extends Annotation> matchConvention(
+    AccessibleObject accessor, 
+    Class<? extends Annotation> expect);
+  
+  boolean isMatch(
+    AccessibleObject accessor, 
+    Class<? extends Annotation> expect);
+  
+  Conventions clone();
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultConventions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultConventions.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultConventions.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultConventions.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,121 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.lang.annotation.Annotation;
+
+import org.apache.abdera.ext.serializer.annotation.Accept;
+import org.apache.abdera.ext.serializer.annotation.Author;
+import org.apache.abdera.ext.serializer.annotation.BaseURI;
+import org.apache.abdera.ext.serializer.annotation.Categories;
+import org.apache.abdera.ext.serializer.annotation.Category;
+import org.apache.abdera.ext.serializer.annotation.Collection;
+import org.apache.abdera.ext.serializer.annotation.Content;
+import org.apache.abdera.ext.serializer.annotation.Contributor;
+import org.apache.abdera.ext.serializer.annotation.Control;
+import org.apache.abdera.ext.serializer.annotation.DateTime;
+import org.apache.abdera.ext.serializer.annotation.Draft;
+import org.apache.abdera.ext.serializer.annotation.Edited;
+import org.apache.abdera.ext.serializer.annotation.Email;
+import org.apache.abdera.ext.serializer.annotation.Entry;
+import org.apache.abdera.ext.serializer.annotation.Extension;
+import org.apache.abdera.ext.serializer.annotation.Generator;
+import org.apache.abdera.ext.serializer.annotation.HrefLanguage;
+import org.apache.abdera.ext.serializer.annotation.ID;
+import org.apache.abdera.ext.serializer.annotation.IRI;
+import org.apache.abdera.ext.serializer.annotation.Icon;
+import org.apache.abdera.ext.serializer.annotation.Label;
+import org.apache.abdera.ext.serializer.annotation.Language;
+import org.apache.abdera.ext.serializer.annotation.Length;
+import org.apache.abdera.ext.serializer.annotation.Link;
+import org.apache.abdera.ext.serializer.annotation.Logo;
+import org.apache.abdera.ext.serializer.annotation.MediaType;
+import org.apache.abdera.ext.serializer.annotation.Person;
+import org.apache.abdera.ext.serializer.annotation.Published;
+import org.apache.abdera.ext.serializer.annotation.Rel;
+import org.apache.abdera.ext.serializer.annotation.Rights;
+import org.apache.abdera.ext.serializer.annotation.Scheme;
+import org.apache.abdera.ext.serializer.annotation.Source;
+import org.apache.abdera.ext.serializer.annotation.Src;
+import org.apache.abdera.ext.serializer.annotation.Subtitle;
+import org.apache.abdera.ext.serializer.annotation.Summary;
+import org.apache.abdera.ext.serializer.annotation.Text;
+import org.apache.abdera.ext.serializer.annotation.Title;
+import org.apache.abdera.ext.serializer.annotation.URI;
+import org.apache.abdera.ext.serializer.annotation.Updated;
+import org.apache.abdera.ext.serializer.annotation.Value;
+import org.apache.abdera.ext.serializer.annotation.Version;
+import org.apache.abdera.ext.serializer.annotation.Workspace;
+
+public class DefaultConventions
+    extends AbstractConventions {
+
+  private static final long serialVersionUID = 6797950641657672805L;
+ 
+  private static final Class<?>[] annotations = 
+   {Accept.class, 
+    Author.class, 
+    BaseURI.class, 
+    Categories.class, 
+    Category.class, 
+    Collection.class, 
+    Content.class, 
+    Contributor.class, 
+    Control.class, 
+    Draft.class, 
+    Edited.class, 
+    Email.class, 
+    Entry.class, 
+    Extension.class, 
+    Generator.class, 
+    HrefLanguage.class, 
+    Icon.class, 
+    ID.class, 
+    Label.class, 
+    Language.class, 
+    Length.class, 
+    Link.class, 
+    Logo.class, 
+    MediaType.class,  
+    Published.class, 
+    Rel.class, 
+    Rights.class, 
+    Scheme.class, 
+    Source.class, 
+    Src.class, 
+    Subtitle.class,
+    Summary.class, 
+    Title.class, 
+    Updated.class, 
+    URI.class, 
+    Value.class, 
+    Version.class, 
+    Workspace.class,
+    Text.class,
+    DateTime.class,
+    Person.class,
+    IRI.class
+   };
+  
+  @SuppressWarnings("unchecked") 
+  public DefaultConventions() {
+    super(false);
+    for (Class<?> type : annotations) setConvention((Class<? extends Annotation>) type);
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultSerializationContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultSerializationContext.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultSerializationContext.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/DefaultSerializationContext.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,73 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.util.ServiceUtil;
+import org.apache.abdera.writer.StreamWriter;
+
+@SuppressWarnings("unchecked")
+public class DefaultSerializationContext 
+  extends AbstractSerializationContext {
+
+  private static final long serialVersionUID = 740460842415905883L;
+
+  private final List<SerializerProvider> providers;
+  
+  public DefaultSerializationContext(StreamWriter streamWriter) {
+    super(streamWriter);
+    initSerializers();
+    providers = loadConverterProviders();
+  }
+  
+  public DefaultSerializationContext(Abdera abdera, StreamWriter streamWriter) {
+    super(abdera, streamWriter);
+    initSerializers();
+    providers = loadConverterProviders();
+  }
+   
+  private void initSerializers() {
+    SerializerProvider[] providers = getConverterProviders();
+    for (SerializerProvider provider : providers) {
+      for (Map.Entry<Class,Serializer> entry : provider) {
+        setSerializer(entry.getKey(), entry.getValue());
+      }
+    }
+  }
+  
+  /**
+   * Returns the listing of registered ConverterProvider implementations
+   */
+  public SerializerProvider[] getConverterProviders() {
+    return providers != null ? 
+      providers.toArray(
+        new SerializerProvider[providers.size()]) : 
+          new SerializerProvider[0];
+  }
+  
+  protected static synchronized List<SerializerProvider> loadConverterProviders() {
+    List<SerializerProvider> providers =
+      ServiceUtil.loadimpls(
+        "META-INF/services/org.apache.abdera.converter.ConverterProvider");
+    return providers;    
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectContext.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectContext.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectContext.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,193 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@SuppressWarnings("unchecked")
+public class ObjectContext {
+
+  private final Class objectType;
+  private final Object parent;
+  private final AccessibleObject accessor;
+  private final Annotation[] annotations;
+  private final Serializer serializer;
+  private final Field[] fields;
+  private final Method[] methods;
+  
+  public ObjectContext(Object object) {
+    this(object,null,null);
+  }
+  
+  public ObjectContext(
+    Object object, 
+    Object parent, 
+    AccessibleObject accessor) {
+      this.objectType = 
+        object != null ? 
+          object.getClass() : 
+        accessor != null ? 
+          AbstractSerializationContext.getReturnType(accessor) : 
+          null;
+      this.parent = parent;
+      this.accessor = accessor;
+      this.annotations = initAnnotations();
+      this.serializer = initSerializer();
+      this.fields = initFields();
+      this.methods = initMethods();
+  }
+  
+  private Field[] initFields() {
+    Field[] fields = objectType.getFields();
+    List<Field> list = new ArrayList<Field>();
+    for (Field field : fields) {
+      int mods = field.getModifiers();
+      // ignore static fields
+      if (!Modifier.isStatic(mods)) {
+        list.add(field);
+      }
+    }
+    return list.toArray(new Field[list.size()]);
+  }
+  
+  private Method[] initMethods() {
+    Method[] methods = objectType.getMethods();
+    List<Method> list = new ArrayList<Method>();
+    for (Method method : methods) {
+      // only methods that have no parameters, return a value, are not
+      // abstract and are not static
+      int mods = method.getModifiers();
+      if (!Modifier.isStatic(mods) &&
+          !Modifier.isAbstract(mods) && 
+          method.getParameterTypes().length == 0 && 
+          method.getReturnType() != Void.class) {
+        list.add(method);
+      }
+    }
+    return list.toArray(new Method[list.size()]);
+  }
+  
+  private Annotation[] initAnnotations() {
+    Map<Class<? extends Annotation>, Annotation> annotations = new 
+    HashMap<Class<? extends Annotation>, Annotation>();
+    if (objectType != null) {
+      for (Annotation annotation : objectType.getAnnotations()) {
+        annotations.put(annotation.annotationType(),annotation);
+      }
+    }
+    if (accessor != null) {
+      for (Annotation annotation : accessor.getAnnotations()) {
+        annotations.put(annotation.annotationType(), annotation);
+      }
+    }
+    return annotations.values().toArray(new Annotation[annotations.size()]);
+  }
+  
+  private Serializer initSerializer() {
+    try {
+      org.apache.abdera.ext.serializer.annotation.Serializer ser = 
+        getAnnotation(
+          org.apache.abdera.ext.serializer.annotation.Serializer.class);
+      if (ser != null) {
+        Class<? extends Serializer> serclass = ser.value();
+        return serclass.newInstance();
+      }
+      return null;
+    } catch (Throwable t) {
+      throw new SerializationException(t);
+    }
+  }
+  
+  public AccessibleObject getAccessor() {
+    return accessor;
+  }
+  
+  public Object getParent() {
+    return parent;
+  }
+  
+  public Class getObjectType() {
+    return objectType;
+  }
+  
+  public <X extends Annotation>X getAnnotation(
+    Class<X> annotationType) {
+      for (Annotation annotation : annotations) {
+        if (annotation.annotationType() == annotationType)
+          return (X)annotation;
+      }
+      return null;
+  }
+  
+  public Annotation[] getAnnotations() {
+    return annotations;
+  }
+  
+  public Serializer getSerializer() {
+    return serializer;
+  }
+  
+  public Field[] getFields() {
+    return fields;
+  }
+  
+  public Method[] getMethods() {
+    return methods;
+  }
+  
+  public AccessibleObject[] getAccessors() {
+    List<AccessibleObject> list = new ArrayList<AccessibleObject>();
+    for (Method method : methods) list.add(method);
+    for (Field field : fields) list.add(field);
+    return list.toArray(new AccessibleObject[list.size()]);
+  }
+  
+  public AccessibleObject[] getAccessors(
+    Class<? extends Annotation> annotation, 
+    Conventions conventions) {
+      List<AccessibleObject> accessors = new ArrayList<AccessibleObject>();
+      for (AccessibleObject accessor : getAccessors()) {
+        if (accessor.isAnnotationPresent(annotation) || 
+            annotation.equals(conventions.matchConvention(accessor))) {
+          accessors.add(accessor);
+        }        
+      }
+      return accessors.toArray(new AccessibleObject[accessors.size()]);
+  }
+  
+  public AccessibleObject getAccessor(
+    Class<? extends Annotation> annotation, 
+    Conventions conventions) {
+      for (AccessibleObject accessor : getAccessors()) {
+        if (accessor.isAnnotationPresent(annotation) || 
+            annotation.equals(conventions.matchConvention(accessor))) {
+          return accessor;
+        }
+      }
+      return null;
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectResponseContext.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectResponseContext.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/ObjectResponseContext.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,197 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.io.IOException;
+import java.lang.reflect.AccessibleObject;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.ext.serializer.annotation.EntityTag;
+import org.apache.abdera.ext.serializer.annotation.LastModified;
+import org.apache.abdera.ext.serializer.annotation.MediaType;
+import org.apache.abdera.model.AtomDate;
+import org.apache.abdera.protocol.server.context.StreamWriterResponseContext;
+import org.apache.abdera.writer.StreamWriter;
+
+public class ObjectResponseContext 
+  extends StreamWriterResponseContext {
+  
+  private final Object object;
+  private final ObjectContext objectContext;
+  private final Conventions conventions;
+  private final Class<? extends SerializationContext> context;
+
+  public ObjectResponseContext(
+    Object object,
+    Abdera abdera, 
+    String encoding, 
+    String sw) {
+      this(object,null,null,abdera,encoding,sw);
+  }
+  
+  public ObjectResponseContext(
+    Object object,
+    Class<? extends SerializationContext> context,
+    Conventions conventions,
+    Abdera abdera, 
+    String encoding, 
+    String sw) {
+      super(abdera, encoding, sw);
+      this.object = object;
+      this.objectContext = new ObjectContext(object);
+      this.conventions = 
+        conventions != null ? 
+          conventions : 
+          new DefaultConventions();
+      this.context = 
+        context != null ? 
+          context : 
+          ConventionSerializationContext.class;
+      init();
+  }
+
+  public ObjectResponseContext(
+    Object object,
+    Abdera abdera, 
+    String encoding) {
+      this(object,null,null,abdera,encoding,null);
+  }
+  
+  public ObjectResponseContext(
+    Object object,
+    Class<? extends SerializationContext> context,
+    Conventions conventions,
+    Abdera abdera, 
+    String encoding) {
+      this(object,context,conventions,abdera,encoding,null);
+  }
+
+  public ObjectResponseContext(
+    Object object,
+    Abdera abdera) {
+      this(object,null,null,abdera,null,null);
+  }
+  
+  public ObjectResponseContext(
+    Object object,
+    Class<? extends SerializationContext> context,
+    Conventions conventions,
+    Abdera abdera) {
+      this(object,context,null,abdera,null,null);
+  }
+
+  private void init() {
+    setContentType(getObjectContentType());
+    setEntityTag(getObjectEntityTag());
+    setLastModified(getObjectLastModified());
+  }
+  
+  private Date getObjectLastModified() {
+    Date date = null;
+    AccessibleObject accessor = 
+      objectContext.getAccessor(
+        LastModified.class, 
+        conventions);
+    if (accessor != null) {
+      Object value = BaseSerializer.eval(accessor, object);
+      date = getDate(value);
+    }
+    return date;
+  }  
+  
+  private Date getDate(  
+    Object value) {
+      Date date = null;
+      if (value == null) return null;
+      if (value instanceof Date) {
+        date = (Date) value;
+      } else if (value instanceof Calendar) {
+        date = ((Calendar)value).getTime();
+      } else if (value instanceof Long) {
+        date = new Date(((Long)value).longValue());
+      } else if (value instanceof String) {
+        date = AtomDate.parse((String)value);
+      } else {
+        date = AtomDate.parse(value.toString());
+      }
+      return date;
+  }
+  
+  private String getObjectEntityTag() {
+    String etag = null;
+    AccessibleObject accessor = 
+      objectContext.getAccessor(
+        EntityTag.class, 
+        conventions);
+    if (accessor != null) {
+      Object value = BaseSerializer.eval(accessor, object);
+      etag = value != null ? BaseSerializer.toString(value) : null;
+    }
+    return etag;
+  }
+  
+  private String getObjectContentType() {
+    String ctype = null;
+    AccessibleObject accessor = 
+      objectContext.getAccessor(
+        MediaType.class, 
+        conventions);
+    if (accessor != null) {
+      Object value = BaseSerializer.eval(accessor, object);
+      ctype = value != null ? BaseSerializer.toString(value) : null;
+    }
+    if (ctype == null) {
+      MediaType content_type = objectContext.getAnnotation(MediaType.class);
+      if (content_type != null && !content_type.value().equals(BaseSerializer.DEFAULT)) {
+        ctype = content_type.value();
+      }
+    }
+    return ctype;
+  }
+  
+  @Override 
+  protected void writeTo(
+    StreamWriter sw) 
+      throws IOException {
+    SerializationContext context = 
+      newSerializationContext(
+        getAbdera(), 
+        conventions, 
+        sw);
+    sw.startDocument();
+    context.serialize(object, objectContext);
+    sw.endDocument();
+  }
+  
+  private SerializationContext newSerializationContext(
+    Abdera abdera, 
+    Conventions conventions,
+    StreamWriter sw) {
+      try {
+        return context.getConstructor(
+          Abdera.class,
+          Conventions.class,
+          StreamWriter.class)
+            .newInstance(abdera,conventions,sw);
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationContext.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationContext.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationContext.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,55 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.io.Serializable;
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.writer.StreamWriter;
+
+public interface SerializationContext
+  extends Serializable {
+
+  Abdera getAbdera();
+  
+  StreamWriter getStreamWriter();
+  
+  void serialize(Object object);
+  
+  void serialize(Object object, ObjectContext objectContext);
+  
+  void serialize(Object object, Serializer serializer);
+  
+  void serialize(Object object, ObjectContext objectContext, Serializer serializer);
+  
+  void setSerializer(Class<?> type, Serializer serializer);
+  
+  Serializer getSerializer(ObjectContext objectContext);
+  
+  boolean hasSerializer(ObjectContext objectContext);
+
+  boolean hasSerializer(Object object);
+  
+  boolean hasSerializer(Object object, Object parent, AccessibleObject accessor);
+
+  boolean hasSerializer(Class<?> type);
+  
+  boolean hasSerializer(AccessibleObject accessor);
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationException.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationException.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationException.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializationException.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,45 @@
+/*
+* 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.abdera.ext.serializer;
+
+public class SerializationException
+    extends RuntimeException {
+
+  private static final long serialVersionUID = 3399703987771955406L;
+
+  public SerializationException() {
+    super();
+  }
+
+  public SerializationException(
+    String message, 
+    Throwable cause) {
+      super(message, cause);
+  }
+
+  public SerializationException(
+    String message) {
+      super(message);
+  }
+
+  public SerializationException(
+    Throwable cause) {
+      super(cause);
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Serializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Serializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Serializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/Serializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,40 @@
+/*
+* 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.abdera.ext.serializer;
+
+
+public abstract class Serializer {
+
+  /**
+   * Serializes the given object to the specified writer
+   */
+  public void serialize(
+    Object object, 
+    SerializationContext serializationContext) {
+      serialize(object, new ObjectContext(object), serializationContext);
+  }
+  
+  /**
+   * Serializes the given object to the specified writer
+   */
+  public abstract void serialize(
+    Object object, 
+    ObjectContext context,
+    SerializationContext serializationContext);
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializerProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializerProvider.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializerProvider.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/SerializerProvider.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,42 @@
+/*
+* 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.abdera.ext.serializer;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+@SuppressWarnings("unchecked") 
+public abstract class SerializerProvider 
+  implements Iterable<Map.Entry<Class,Serializer>>{
+
+  protected Map<Class,Serializer> serializers = 
+    new HashMap<Class,Serializer>();
+  
+  protected void setConverter(
+    Class type, 
+    Serializer serializer) {
+      serializers.put(type, serializer);
+  }
+
+  public Iterator<Entry<Class, Serializer>> iterator() {
+    return serializers.entrySet().iterator();
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Accept.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Accept.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Accept.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Accept.java Mon Jan 28 13:26:00 2008
@@ -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.abdera.ext.serializer.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*accept")
+public @interface Accept {}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Attribute.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Attribute.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Attribute.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Attribute.java Mon Jan 28 13:26:00 2008
@@ -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.abdera.ext.serializer.annotation;
+
+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.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*attribute")
+public @interface Attribute {
+  String name()   default "##default";
+  String ns()     default "##default";
+  String prefix() default "##default";
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Author.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Author.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Author.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Author.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,31 @@
+/*
+* 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.abdera.ext.serializer.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+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,METHOD,FIELD})
+@Convention(".*author(?:s)?")
+public @interface Author {}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/BaseURI.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/BaseURI.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/BaseURI.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/BaseURI.java Mon Jan 28 13:26:00 2008
@@ -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.abdera.ext.serializer.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*baseuri")
+public @interface BaseURI {}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Categories.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Categories.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Categories.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Categories.java Mon Jan 28 13:26:00 2008
@@ -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.abdera.ext.serializer.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.abdera.ext.serializer.impl.CategoriesSerializer;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*categories")
+@Serializer(CategoriesSerializer.class)
+public @interface Categories {}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Category.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Category.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Category.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/annotation/Category.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,37 @@
+/*
+* 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.abdera.ext.serializer.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.abdera.ext.serializer.impl.CategorySerializer;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*category|.*categories")
+@Serializer(CategorySerializer.class)
+public @interface Category {
+  String scheme() default "##default";
+  String label() default "##default";
+}



Mime
View raw message