You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/06/24 06:57:30 UTC

[05/23] [OLINGO-317] First presentable state

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
index 6b38382..22d5dc8 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/XMLServiceDocumentDeserializer.java
@@ -18,22 +18,27 @@
  */
 package org.apache.olingo.client.core.data;
 
-import org.apache.olingo.commons.core.data.ODataJacksonDeserializer;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
-
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.JsonDeserializer;
 
-public class XMLServiceDocumentDeserializer extends ODataJacksonDeserializer<ResWrap<ServiceDocument>> {
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.dataformat.xml.XmlFactory;
+import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
+
+public class XMLServiceDocumentDeserializer extends JsonDeserializer {
+
+  public XMLServiceDocumentDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
   private String getName(final JsonParser jp) throws IOException {
     String title = jp.nextTextValue();
@@ -47,11 +52,11 @@ public class XMLServiceDocumentDeserializer extends ODataJacksonDeserializer<Res
   }
 
   private ServiceDocumentItemImpl deserializeElement(final JsonParser jp, final String elementName)
-          throws IOException {
+      throws IOException {
 
     final ServiceDocumentItemImpl element = new ServiceDocumentItemImpl();
     for (; jp.getCurrentToken() != JsonToken.END_OBJECT
-            || !elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
+        || !elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
 
       final JsonToken token = jp.getCurrentToken();
       if (token == JsonToken.FIELD_NAME) {
@@ -66,20 +71,16 @@ public class XMLServiceDocumentDeserializer extends ODataJacksonDeserializer<Res
     return element;
   }
 
-  @Override
-  protected ResWrap<ServiceDocument> doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<ServiceDocument> doDeserialize(final JsonParser jp) throws IOException {
 
-    final AbstractServiceDocument sdoc = ODataServiceVersion.V30 == version
-            ? new org.apache.olingo.client.core.data.v3.XMLServiceDocumentImpl()
-            : new org.apache.olingo.client.core.data.v4.XMLServiceDocumentImpl();
+    ServiceDocumentImpl sdoc = new ServiceDocumentImpl();
 
     URI contextURL = null;
     String metadataETag = null;
     String base = null;
 
     for (; jp.getCurrentToken() != JsonToken.END_OBJECT
-            || !"service".equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
+        || !"service".equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
 
       final JsonToken token = jp.getCurrentToken();
       if (token == JsonToken.FIELD_NAME) {
@@ -112,11 +113,20 @@ public class XMLServiceDocumentDeserializer extends ODataJacksonDeserializer<Res
     }
 
     sdoc.setMetadata((contextURL == null
-            ? URIUtils.getURI(base, "$metadata")
-            : URIUtils.getURI(base, contextURL.toASCIIString())).toASCIIString());
+        ? URIUtils.getURI(base, "$metadata")
+        : URIUtils.getURI(base, contextURL.toASCIIString())).toASCIIString());
 
     return new ResWrap<ServiceDocument>(
-            contextURL == null ? null : URIUtils.getURI(sdoc.getBaseURI(), contextURL),
-            metadataETag, sdoc);
+        contextURL == null ? null : URIUtils.getURI(sdoc.getBaseURI(), contextURL),
+        metadataETag, sdoc);
+  }
+
+  public ResWrap<ServiceDocument> toServiceDocument(InputStream input) throws ODataDeserializerException {
+    try {
+      JsonParser parser = new XmlFactory().createParser(input);
+      return doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/JSONServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/JSONServiceDocumentImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/JSONServiceDocumentImpl.java
deleted file mode 100644
index af957a1..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/JSONServiceDocumentImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.
- */
-package org.apache.olingo.client.core.data.v3;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-
-import org.apache.olingo.client.core.data.AbstractServiceDocument;
-import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
-
-/**
- * Service document, represented via JSON.
- */
-@JsonDeserialize(using = JSONServiceDocumentDeserializer.class)
-public class JSONServiceDocumentImpl extends AbstractServiceDocument {
-
-  private static final long serialVersionUID = 4195734928526398830L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/XMLServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/XMLServiceDocumentImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/XMLServiceDocumentImpl.java
deleted file mode 100644
index e09b092..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v3/XMLServiceDocumentImpl.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-package org.apache.olingo.client.core.data.v3;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.core.data.AbstractServiceDocument;
-import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
-
-@JsonDeserialize(using = XMLServiceDocumentDeserializer.class)
-public class XMLServiceDocumentImpl extends AbstractServiceDocument implements ServiceDocument {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/AbstractServiceDocument.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/AbstractServiceDocument.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/AbstractServiceDocument.java
deleted file mode 100644
index 45ce766..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/AbstractServiceDocument.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.
- */
-package org.apache.olingo.client.core.data.v4;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.client.api.data.ServiceDocumentItem;
-
-public abstract class AbstractServiceDocument
-        extends org.apache.olingo.client.core.data.AbstractServiceDocument {
-
-  private List<ServiceDocumentItem> functionImports = new ArrayList<ServiceDocumentItem>();
-
-  private List<ServiceDocumentItem> singletons = new ArrayList<ServiceDocumentItem>();
-
-  private List<ServiceDocumentItem> relatedServiceDocuments = new ArrayList<ServiceDocumentItem>();
-
-  @Override
-  public List<ServiceDocumentItem> getFunctionImports() {
-    return functionImports;
-  }
-
-  @Override
-  public List<ServiceDocumentItem> getSingletons() {
-    return singletons;
-  }
-
-  @Override
-  public List<ServiceDocumentItem> getRelatedServiceDocuments() {
-    return relatedServiceDocuments;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/JSONServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/JSONServiceDocumentImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/JSONServiceDocumentImpl.java
deleted file mode 100644
index f3dfd91..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/JSONServiceDocumentImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-package org.apache.olingo.client.core.data.v4;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-@JsonDeserialize(using = JSONServiceDocumentDeserializer.class)
-public class JSONServiceDocumentImpl extends AbstractServiceDocument implements ServiceDocument {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/XMLServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/XMLServiceDocumentImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/XMLServiceDocumentImpl.java
deleted file mode 100644
index b3c64b6..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/v4/XMLServiceDocumentImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-package org.apache.olingo.client.core.data.v4;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
-
-@JsonDeserialize(using = XMLServiceDocumentDeserializer.class)
-public class XMLServiceDocumentImpl extends AbstractServiceDocument implements ServiceDocument {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
index c52b0c1..5b0376b 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.op;
 import java.io.StringWriter;
 import java.net.URI;
 import java.util.Iterator;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.data.ServiceDocument;
@@ -65,23 +66,23 @@ import org.apache.olingo.commons.api.edm.EdmStructuredType;
 import org.apache.olingo.commons.api.edm.EdmType;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.op.ODataSerializerException;
 import org.apache.olingo.commons.core.data.CollectionValueImpl;
 import org.apache.olingo.commons.core.data.ComplexValueImpl;
+import org.apache.olingo.commons.core.data.EntityImpl;
+import org.apache.olingo.commons.core.data.EntitySetImpl;
 import org.apache.olingo.commons.core.data.GeospatialValueImpl;
-import org.apache.olingo.commons.core.data.JSONPropertyImpl;
 import org.apache.olingo.commons.core.data.LinkImpl;
 import org.apache.olingo.commons.core.data.NullValueImpl;
 import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractODataBinder implements CommonODataBinder {
 
-  private static final long serialVersionUID = 454285889193689536L;
-
   /**
    * Logger.
    */
@@ -99,15 +100,15 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
 
     for (ServiceDocumentItem entitySet : resource.getEntitySets()) {
       serviceDocument.getEntitySets().
-              put(entitySet.getName(), URIUtils.getURI(resource.getBaseURI(), entitySet.getUrl()));
+          put(entitySet.getName(), URIUtils.getURI(resource.getBaseURI(), entitySet.getUrl()));
     }
 
     return serviceDocument;
   }
 
   @Override
-  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet, final Class<? extends EntitySet> reference) {
-    final EntitySet entitySet = ResourceFactory.newEntitySet(reference);
+  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
+    final EntitySet entitySet = new EntitySetImpl();
 
     entitySet.setCount(odataEntitySet.getCount());
 
@@ -117,13 +118,13 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
 
     for (CommonODataEntity entity : odataEntitySet.getEntities()) {
-      entitySet.getEntities().add(getEntity(entity, ResourceFactory.entityClassForEntitySet(reference)));
+      entitySet.getEntities().add(getEntity(entity));
     }
 
     return entitySet;
   }
 
-  protected void links(final ODataLinked odataLinked, final Linked linked, final Class<? extends Entity> reference) {
+  protected void links(final ODataLinked odataLinked, final Linked linked) {
     // -------------------------------------------------------------
     // Append navigation links (handling inline entity / entity set as well)
     // -------------------------------------------------------------
@@ -131,8 +132,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     for (ODataLink link : odataLinked.getNavigationLinks()) {
       // append link 
       LOG.debug("Append navigation link\n{}", link);
-      linked.getNavigationLinks().add(getLink(link,
-              ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
+      linked.getNavigationLinks().add(getLink(link));
     }
     // -------------------------------------------------------------
 
@@ -141,15 +141,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     // -------------------------------------------------------------
     for (ODataLink link : odataLinked.getAssociationLinks()) {
       LOG.debug("Append association link\n{}", link);
-      linked.getAssociationLinks().add(getLink(link,
-              ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
+      linked.getAssociationLinks().add(getLink(link));
     }
     // -------------------------------------------------------------
   }
 
   @Override
-  public Entity getEntity(final CommonODataEntity odataEntity, final Class<? extends Entity> reference) {
-    final Entity entity = ResourceFactory.newEntity(reference);
+  public Entity getEntity(final CommonODataEntity odataEntity) {
+    final Entity entity = new EntityImpl();
 
     entity.setType(odataEntity.getTypeName() == null ? null : odataEntity.getTypeName().toString());
 
@@ -174,15 +173,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
     // -------------------------------------------------------------
 
-    links(odataEntity, entity, reference);
+    links(odataEntity, entity);
 
     // -------------------------------------------------------------
     // Append edit-media links
     // -------------------------------------------------------------
     for (ODataLink link : odataEntity.getMediaEditLinks()) {
       LOG.debug("Append edit-media link\n{}", link);
-      entity.getMediaEditLinks().add(getLink(link,
-              ResourceFactory.formatForEntityClass(reference) == ODataPubFormat.ATOM));
+      entity.getMediaEditLinks().add(getLink(link));
     }
     // -------------------------------------------------------------
 
@@ -193,14 +191,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
 
     for (CommonODataProperty property : odataEntity.getProperties()) {
-      entity.getProperties().add(getProperty(property, reference));
+      entity.getProperties().add(getProperty(property));
     }
 
     return entity;
   }
 
   @Override
-  public Link getLink(final ODataLink link, boolean isXML) {
+  public Link getLink(final ODataLink link) {
     final Link linkResource = new LinkImpl();
     linkResource.setRel(link.getRel());
     linkResource.setTitle(link.getName());
@@ -213,40 +211,40 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       final CommonODataEntity inlineEntity = ((ODataInlineEntity) link).getEntity();
       LOG.debug("Append in-line entity\n{}", inlineEntity);
 
-      linkResource.setInlineEntity(getEntity(inlineEntity, ResourceFactory.entityClassForFormat(isXML)));
+      linkResource.setInlineEntity(getEntity(inlineEntity));
     } else if (link instanceof ODataInlineEntitySet) {
       // append inline entity set
       final CommonODataEntitySet InlineEntitySet = ((ODataInlineEntitySet) link).getEntitySet();
       LOG.debug("Append in-line entity set\n{}", InlineEntitySet);
 
-      linkResource.setInlineEntitySet(getEntitySet(InlineEntitySet, ResourceFactory.entitySetClassForFormat(isXML)));
+      linkResource.setInlineEntitySet(getEntitySet(InlineEntitySet));
     }
 
     return linkResource;
   }
 
-  protected Value getValue(final ODataValue value, final Class<? extends Entity> reference) {
+  protected Value getValue(final ODataValue value) {
     Value valueResource = null;
 
     if (value == null) {
       valueResource = new NullValueImpl();
     } else if (value.isPrimitive()) {
       valueResource = value.asPrimitive().getTypeKind().isGeospatial()
-              ? new GeospatialValueImpl((Geospatial) value.asPrimitive().toValue())
-              : new PrimitiveValueImpl(value.asPrimitive().toString());
+          ? new GeospatialValueImpl((Geospatial) value.asPrimitive().toValue())
+          : new PrimitiveValueImpl(value.asPrimitive().toString());
     } else if (value.isComplex()) {
       final ODataComplexValue<? extends CommonODataProperty> _value = value.asComplex();
       valueResource = new ComplexValueImpl();
 
       for (final Iterator<? extends CommonODataProperty> itor = _value.iterator(); itor.hasNext();) {
-        valueResource.asComplex().get().add(getProperty(itor.next(), reference));
+        valueResource.asComplex().get().add(getProperty(itor.next()));
       }
     } else if (value.isCollection()) {
       final ODataCollectionValue<? extends ODataValue> _value = value.asCollection();
       valueResource = new CollectionValueImpl();
 
       for (final Iterator<? extends ODataValue> itor = _value.iterator(); itor.hasNext();) {
-        valueResource.asCollection().get().add(getValue(itor.next(), reference));
+        valueResource.asCollection().get().add(getValue(itor.next()));
       }
     }
 
@@ -259,19 +257,21 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
   public CommonODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
     if (LOG.isDebugEnabled()) {
       final StringWriter writer = new StringWriter();
-      client.getSerializer().entitySet(resource.getPayload(), writer);
+      try {
+        client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
+      } catch (final ODataSerializerException e) {}
       writer.flush();
       LOG.debug("EntitySet -> ODataEntitySet:\n{}", writer.toString());
     }
 
     final URI base = resource.getContextURL() == null
-            ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
+        ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
 
     final URI next = resource.getPayload().getNext();
 
     final CommonODataEntitySet entitySet = next == null
-            ? client.getObjectFactory().newEntitySet()
-            : client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));
+        ? client.getObjectFactory().newEntitySet()
+        : client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));
 
     if (resource.getPayload().getCount() != null) {
       entitySet.setCount(resource.getPayload().getCount());
@@ -279,14 +279,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
 
     for (Entity entityResource : resource.getPayload().getEntities()) {
       add(entitySet, getODataEntity(
-              new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource)));
+          new ResWrap<Entity>(resource.getContextURL(), resource.getMetadataETag(), entityResource)));
     }
 
     return entitySet;
   }
 
   protected void odataNavigationLinks(final EdmType edmType,
-          final Linked linked, final ODataLinked odataLinked, final String metadataETag, final URI base) {
+      final Linked linked, final ODataLinked odataLinked, final String metadataETag, final URI base) {
 
     for (Link link : linked.getNavigationLinks()) {
       final Entity inlineEntity = link.getInlineEntity();
@@ -298,35 +298,35 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
           final EdmNavigationProperty navProp = ((EdmStructuredType) edmType).getNavigationProperty(link.getTitle());
           if (navProp != null) {
             linkType = navProp.isCollection()
-                    ? ODataLinkType.ENTITY_SET_NAVIGATION
-                    : ODataLinkType.ENTITY_NAVIGATION;
+                ? ODataLinkType.ENTITY_SET_NAVIGATION
+                : ODataLinkType.ENTITY_NAVIGATION;
           }
         }
         if (linkType == null) {
           linkType = link.getType() == null
-                  ? ODataLinkType.ENTITY_NAVIGATION
-                  : ODataLinkType.fromString(client.getServiceVersion(), link.getRel(), link.getType());
+              ? ODataLinkType.ENTITY_NAVIGATION
+              : ODataLinkType.fromString(client.getServiceVersion(), link.getRel(), link.getType());
         }
 
         odataLinked.addLink(linkType == ODataLinkType.ENTITY_NAVIGATION
-                ? client.getObjectFactory().
+            ? client.getObjectFactory().
                 newEntityNavigationLink(link.getTitle(), URIUtils.getURI(base, link.getHref()))
-                : client.getObjectFactory().
+            : client.getObjectFactory().
                 newEntitySetNavigationLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
       } else if (inlineEntity != null) {
         odataLinked.addLink(new ODataInlineEntity(client.getServiceVersion(),
-                URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_NAVIGATION, link.getTitle(),
-                getODataEntity(new ResWrap<Entity>(
-                                inlineEntity.getBaseURI() == null ? base : inlineEntity.getBaseURI(),
-                                metadataETag,
-                                inlineEntity))));
+            URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_NAVIGATION, link.getTitle(),
+            getODataEntity(new ResWrap<Entity>(
+                inlineEntity.getBaseURI() == null ? base : inlineEntity.getBaseURI(),
+                metadataETag,
+                inlineEntity))));
       } else {
         odataLinked.addLink(new ODataInlineEntitySet(client.getServiceVersion(),
-                URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_SET_NAVIGATION, link.getTitle(),
-                getODataEntitySet(new ResWrap<EntitySet>(
-                                inlineEntitySet.getBaseURI() == null ? base : inlineEntitySet.getBaseURI(),
-                                metadataETag,
-                                inlineEntitySet))));
+            URIUtils.getURI(base, link.getHref()), ODataLinkType.ENTITY_SET_NAVIGATION, link.getTitle(),
+            getODataEntitySet(new ResWrap<EntitySet>(
+                inlineEntitySet.getBaseURI() == null ? base : inlineEntitySet.getBaseURI(),
+                metadataETag,
+                inlineEntitySet))));
       }
     }
   }
@@ -368,7 +368,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
         }
         if (type == null) {
           type = new EdmTypeInfo.Builder().setEdm(edm).
-                  setTypeExpression(contextURL.getEntitySetOrSingletonOrType()).build().getType();
+              setTypeExpression(contextURL.getEntitySetOrSingletonOrType()).build().getType();
         }
       } else {
         type = edm.getEntityType(new FullQualifiedName(contextURL.getDerivedEntity()));
@@ -382,13 +382,15 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
   public CommonODataEntity getODataEntity(final ResWrap<Entity> resource) {
     if (LOG.isDebugEnabled()) {
       final StringWriter writer = new StringWriter();
-      client.getSerializer().entity(resource.getPayload(), writer);
+      try {
+        client.getSerializer(ODataFormat.JSON).write(writer, resource.getPayload());
+      } catch (final ODataSerializerException e) {}
       writer.flush();
       LOG.debug("EntityResource -> ODataEntity:\n{}", writer.toString());
     }
 
     final URI base = resource.getContextURL() == null
-            ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
+        ? resource.getPayload().getBaseURI() : resource.getContextURL().getServiceRoot();
 
     final EdmType edmType = findType(resource.getContextURL(), resource.getMetadataETag());
     FullQualifiedName typeName = null;
@@ -401,9 +403,9 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
     }
 
     final CommonODataEntity entity = resource.getPayload().getSelfLink() == null
-            ? client.getObjectFactory().newEntity(typeName)
-            : client.getObjectFactory().newEntity(typeName,
-                    URIUtils.getURI(base, resource.getPayload().getSelfLink().getHref()));
+        ? client.getObjectFactory().newEntity(typeName)
+        : client.getObjectFactory().newEntity(typeName,
+            URIUtils.getURI(base, resource.getPayload().getSelfLink().getHref()));
 
     if (StringUtils.isNotBlank(resource.getPayload().getETag())) {
       entity.setETag(resource.getPayload().getETag());
@@ -415,14 +417,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
 
     for (Link link : resource.getPayload().getAssociationLinks()) {
       entity.addLink(client.getObjectFactory().
-              newAssociationLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
+          newAssociationLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
     }
 
     odataNavigationLinks(edmType, resource.getPayload(), entity, resource.getMetadataETag(), base);
 
     for (Link link : resource.getPayload().getMediaEditLinks()) {
       entity.addLink(client.getObjectFactory().
-              newMediaEditLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
+          newMediaEditLink(link.getTitle(), URIUtils.getURI(base, link.getHref())));
     }
 
     for (ODataOperation operation : resource.getPayload().getOperations()) {
@@ -452,7 +454,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
   }
 
   protected EdmTypeInfo buildTypeInfo(final ContextURL contextURL, final String metadataETag,
-          final String propertyName, final String propertyType) {
+      final String propertyName, final String propertyType) {
 
     FullQualifiedName typeName = null;
     final EdmType type = findType(contextURL, metadataETag);
@@ -488,23 +490,23 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
   protected abstract CommonODataProperty getODataProperty(EdmType type, Property resource);
 
   protected ODataValue getODataValue(final FullQualifiedName type,
-          final Valuable valuable, final ContextURL contextURL, final String metadataETag) {
+      final Valuable valuable, final ContextURL contextURL, final String metadataETag) {
 
     ODataValue value = null;
-    if (valuable.getValue().isPrimitive()) {
+    if (valuable.getValue().isGeospatial()) {
       value = client.getObjectFactory().newPrimitiveValueBuilder().
-              setText(valuable.getValue().asPrimitive().get()).
-              setType(type == null || !EdmPrimitiveType.EDM_NAMESPACE.equals(type.getNamespace())
-                      ? null
-                      : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), type.toString())).build();
-    } else if (valuable.getValue().isGeospatial()) {
+          setValue(valuable.getValue().asGeospatial().get()).
+          setType(type == null
+              || EdmPrimitiveTypeKind.Geography.getFullQualifiedName().equals(type)
+              || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName().equals(type)
+              ? valuable.getValue().asGeospatial().get().getEdmPrimitiveTypeKind()
+              : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), type.toString())).build();
+    } else if (valuable.getValue().isPrimitive()) {
       value = client.getObjectFactory().newPrimitiveValueBuilder().
-              setValue(valuable.getValue().asGeospatial().get()).
-              setType(type == null
-                      || EdmPrimitiveTypeKind.Geography.getFullQualifiedName().equals(type)
-                      || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName().equals(type)
-                      ? valuable.getValue().asGeospatial().get().getEdmPrimitiveTypeKind()
-                      : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), type.toString())).build();
+          setText(valuable.getValue().asPrimitive().get()).
+          setType(type == null || !EdmPrimitiveType.EDM_NAMESPACE.equals(type.getNamespace())
+              ? null
+              : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), type.toString())).build();
     } else if (valuable.getValue().isComplex()) {
       value = client.getObjectFactory().newComplexValue(type == null ? null : type.toString());
 
@@ -515,7 +517,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
       value = client.getObjectFactory().newCollectionValue(type == null ? null : "Collection(" + type.toString() + ")");
 
       for (Value _value : valuable.getValue().asCollection().get()) {
-        final Property fake = new JSONPropertyImpl();
+        final Property fake = new PropertyImpl();
         fake.setValue(_value);
         value.asCollection().add(getODataValue(type, fake, contextURL, metadataETag));
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
index 18aa0cf..1b60736 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataReader.java
@@ -21,6 +21,7 @@ package org.apache.olingo.client.core.op;
 import java.io.InputStream;
 import java.net.URI;
 import java.util.Map;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.CommonODataClient;
 import org.apache.olingo.client.api.data.ServiceDocument;
@@ -43,14 +44,13 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
 import org.apache.olingo.commons.api.format.ODataValueFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractODataReader implements CommonODataReader {
 
-  private static final long serialVersionUID = -1988865870981207079L;
-
   /**
    * Logger.
    */
@@ -64,7 +64,7 @@ public abstract class AbstractODataReader implements CommonODataReader {
 
   @Override
   public Edm readMetadata(final InputStream input) {
-    return readMetadata(client.getDeserializer().toMetadata(input).getSchemaByNsOrAlias());
+    return readMetadata(client.getDeserializer(ODataFormat.XML).toMetadata(input).getSchemaByNsOrAlias());
   }
 
   @Override
@@ -73,19 +73,21 @@ public abstract class AbstractODataReader implements CommonODataReader {
   }
 
   @Override
-  public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format) {
+  public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
     return client.getBinder().getODataServiceDocument(
-            client.getDeserializer().toServiceDocument(input, format).getPayload());
+            client.getDeserializer(format).toServiceDocument(input).getPayload());
   }
 
   @Override
-  public ODataError readError(final InputStream inputStream, final boolean isXML) {
-    return client.getDeserializer().toError(inputStream, isXML);
+  public ODataError readError(final InputStream inputStream, final ODataFormat format )
+      throws ODataDeserializerException {
+    return client.getDeserializer(format).toError(inputStream);
   }
 
   @Override
-  @SuppressWarnings("unchecked")
-  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference) {
+  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference)
+      throws ODataDeserializerException {
     ResWrap<T> res;
 
     try {
@@ -96,20 +98,20 @@ public abstract class AbstractODataReader implements CommonODataReader {
                 reference.cast(new ODataEntitySetIterator<CommonODataEntitySet, CommonODataEntity>(
                                 client, src, ODataPubFormat.fromString(format))));
       } else if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
-        final ResWrap<EntitySet> resource = client.getDeserializer().
-                toEntitySet(src, ODataPubFormat.fromString(format));
+        final ResWrap<EntitySet> resource = client.getDeserializer(ODataPubFormat.fromString(format))
+            .toEntitySet(src);
         res = new ResWrap<T>(
                 resource.getContextURL(),
                 resource.getMetadataETag(),
                 reference.cast(client.getBinder().getODataEntitySet(resource)));
       } else if (CommonODataEntity.class.isAssignableFrom(reference)) {
-        final ResWrap<Entity> container = client.getDeserializer().toEntity(src, ODataPubFormat.fromString(format));
+        final ResWrap<Entity> container = client.getDeserializer(ODataPubFormat.fromString(format)).toEntity(src);
         res = new ResWrap<T>(
                 container.getContextURL(),
                 container.getMetadataETag(),
                 reference.cast(client.getBinder().getODataEntity(container)));
       } else if (CommonODataProperty.class.isAssignableFrom(reference)) {
-        final ResWrap<Property> container = client.getDeserializer().toProperty(src, ODataFormat.fromString(format));
+        final ResWrap<Property> container = client.getDeserializer(ODataFormat.fromString(format)).toProperty(src);
         res = new ResWrap<T>(
                 container.getContextURL(),
                 container.getMetadataETag(),
@@ -130,7 +132,7 @@ public abstract class AbstractODataReader implements CommonODataReader {
                 reference.cast(readMetadata(src)));
       } else if (ODataServiceDocument.class.isAssignableFrom(reference)) {
         final ResWrap<ServiceDocument> resource =
-                client.getDeserializer().toServiceDocument(src, ODataFormat.fromString(format));
+                client.getDeserializer(ODataFormat.fromString(format)).toServiceDocument(src);
         res = new ResWrap<T>(
                 resource.getContextURL(),
                 resource.getMetadataETag(),
@@ -139,7 +141,7 @@ public abstract class AbstractODataReader implements CommonODataReader {
         res = new ResWrap<T>(
                 (URI) null,
                 null,
-                reference.cast(readError(src, !format.toString().contains("json"))));
+                reference.cast(readError(src, ODataFormat.fromString(format))));
       } else {
         throw new IllegalArgumentException("Invalid reference type " + reference);
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
index a1c7e5e..71fe85d 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
@@ -18,38 +18,46 @@
  */
 package org.apache.olingo.client.core.op;
 
-import org.apache.olingo.commons.core.op.ResourceFactory;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
 import java.util.Collection;
 import java.util.Collections;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.op.ODataWriter;
+import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataLink;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.client.api.op.ODataWriter;
+import org.apache.olingo.commons.api.op.ODataSerializerException;
 
 public class ODataWriterImpl implements ODataWriter {
 
-  private static final long serialVersionUID = 3265794768412314485L;
-
-  protected final CommonODataClient client;
+  protected final CommonODataClient<?> client;
 
-  public ODataWriterImpl(final CommonODataClient client) {
+  public ODataWriterImpl(final CommonODataClient<?> client) {
     this.client = client;
   }
 
   @Override
-  public InputStream writeEntities(final Collection<CommonODataEntity> entities, final ODataPubFormat format) {
-    final ByteArrayOutputStream output = new ByteArrayOutputStream();
+  public InputStream writeEntities(final Collection<CommonODataEntity> entities, final ODataPubFormat format)
+      throws ODataSerializerException {
+    ByteArrayOutputStream output = new ByteArrayOutputStream();
+    OutputStreamWriter writer;
+    try {
+      writer = new OutputStreamWriter(output, Constants.UTF8);
+    } catch (final UnsupportedEncodingException e) {
+      writer = null;
+    }
     try {
       for (CommonODataEntity entity : entities) {
-        client.getSerializer().entity(client.getBinder().getEntity(
-                entity, ResourceFactory.entityClassForFormat(format == ODataPubFormat.ATOM)), output);
+        client.getSerializer(format).write(writer, client.getBinder().getEntity(entity));
       }
 
       return new ByteArrayInputStream(output.toByteArray());
@@ -59,16 +67,23 @@ public class ODataWriterImpl implements ODataWriter {
   }
 
   @Override
-  public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format) {
+  public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format)
+      throws ODataSerializerException {
     return writeEntities(Collections.<CommonODataEntity>singleton(entity), format);
   }
 
   @Override
-  public InputStream writeProperty(final CommonODataProperty property, final ODataFormat format) {
+  public InputStream writeProperty(final CommonODataProperty property, final ODataFormat format)
+      throws ODataSerializerException {
     final ByteArrayOutputStream output = new ByteArrayOutputStream();
+    OutputStreamWriter writer;
+    try {
+      writer = new OutputStreamWriter(output, Constants.UTF8);
+    } catch (final UnsupportedEncodingException e) {
+      writer = null;
+    }
     try {
-      client.getSerializer().property(client.getBinder().getProperty(
-              property, ResourceFactory.entityClassForFormat(format == ODataFormat.XML)), output);
+      client.getSerializer(format).write(writer, client.getBinder().getProperty(property));
 
       return new ByteArrayInputStream(output.toByteArray());
     } finally {
@@ -77,10 +92,16 @@ public class ODataWriterImpl implements ODataWriter {
   }
 
   @Override
-  public InputStream writeLink(final ODataLink link, final ODataFormat format) {
+  public InputStream writeLink(final ODataLink link, final ODataFormat format) throws ODataSerializerException {
     final ByteArrayOutputStream output = new ByteArrayOutputStream();
+    OutputStreamWriter writer;
+    try {
+      writer = new OutputStreamWriter(output, Constants.UTF8);
+    } catch (final UnsupportedEncodingException e) {
+      writer = null;
+    }
     try {
-      client.getSerializer().link(client.getBinder().getLink(link, format == ODataFormat.XML), format, output);
+      client.getSerializer(format).write(writer, client.getBinder().getLink(link));
 
       return new ByteArrayInputStream(output.toByteArray());
     } finally {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
index e59ad66..932a766 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
@@ -35,21 +35,19 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.domain.v3.ODataPropertyImpl;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 
 public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
 
-  private static final long serialVersionUID = 8970843539708952308L;
-
   public ODataBinderImpl(final ODataClientImpl client) {
     super(client);
   }
 
   @Override
   public void add(final ODataComplexValue<CommonODataProperty> complex, final CommonODataProperty property) {
-    complex.add((ODataProperty) property);
+    complex.add(property);
   }
 
   @Override
@@ -63,10 +61,10 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
   }
 
   @Override
-  public Property getProperty(final CommonODataProperty property, final Class<? extends Entity> reference) {
-    final Property propertyResource = ResourceFactory.newProperty(reference);
+  public Property getProperty(final CommonODataProperty property) {
+    final Property propertyResource = new PropertyImpl();
     propertyResource.setName(property.getName());
-    propertyResource.setValue(getValue(property.getValue(), reference));
+    propertyResource.setValue(getValue(property.getValue()));
 
     if (property.hasPrimitiveValue()) {
       propertyResource.setType(property.getPrimitiveValue().getTypeName());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataDeserializerImpl.java
index 2c5ae59..d238a75 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataDeserializerImpl.java
@@ -20,27 +20,31 @@ package org.apache.olingo.client.core.op.impl.v3;
 
 import java.io.InputStream;
 
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.edm.xml.XMLMetadata;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.client.api.op.v3.ODataDeserializer;
-import org.apache.olingo.commons.core.data.v3.JSONLinkCollectionImpl;
-import org.apache.olingo.commons.core.data.v3.XMLLinkCollectionImpl;
-import org.apache.olingo.client.core.data.v3.JSONServiceDocumentImpl;
-import org.apache.olingo.client.core.data.v4.XMLServiceDocumentImpl;
+import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
+import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
 import org.apache.olingo.client.core.edm.xml.v3.EdmxImpl;
 import org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl;
 import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.core.op.AbstractODataDeserializer;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.AtomDeserializer;
+import org.apache.olingo.commons.core.op.AbstractODataDeserializer;
 
 public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
 
-  private static final long serialVersionUID = -8221085862548914611L;
+  private final Format format;
 
-  public ODataDeserializerImpl(final ODataServiceVersion version) {
-    super(version);
+  public ODataDeserializerImpl(final ODataServiceVersion version, final Format format) {
+    super(version, format);
+    this.format = format;
   }
 
   @Override
@@ -53,16 +57,20 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
   }
 
   @Override
-  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input, final ODataFormat format) {
-    return format == ODataFormat.XML
-            ? this.<ServiceDocument, XMLServiceDocumentImpl>xml(input, XMLServiceDocumentImpl.class)
-            : this.<ServiceDocument, JSONServiceDocumentImpl>json(input, JSONServiceDocumentImpl.class);
+  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) throws ODataDeserializerException {
+    return format == ODataFormat.XML ?
+        new XMLServiceDocumentDeserializer(version, false).toServiceDocument(input) :
+        new JSONServiceDocumentDeserializer(version, false).toServiceDocument(input);
   }
 
   @Override
-  public ResWrap<LinkCollection> toLinkCollection(final InputStream input, final ODataFormat format) {
-    return format == ODataFormat.XML
-            ? this.<LinkCollection, XMLLinkCollectionImpl>atom(input, XMLLinkCollectionImpl.class)
-            : this.<LinkCollection, JSONLinkCollectionImpl>json(input, JSONLinkCollectionImpl.class);
+  public ResWrap<LinkCollection> toLinkCollection(final InputStream input) throws ODataDeserializerException {
+    try {
+      return format == ODataFormat.XML ?
+          new AtomDeserializer(version).linkCollection(input) :
+          null; //json(input, LinkCollection.class);
+    } catch (final XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
index c64d5c8..16a897d 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java
@@ -31,42 +31,46 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntity;
 import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v3.ODataProperty;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 
 public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
 
-  private static final long serialVersionUID = -2481293269536406956L;
-
   public ODataReaderImpl(final ODataClient client) {
     super(client);
   }
 
   @Override
-  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
-    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer().toEntitySet(input, format));
+  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
   }
 
   @Override
-  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
-    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer().toEntity(input, format));
+  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
   }
 
   @Override
-  public ODataProperty readProperty(final InputStream input, final ODataFormat format) {
-    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer().toProperty(input, format));
+  public ODataProperty readProperty(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
   }
 
   @Override
-  public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format) {
+  public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
     return ((ODataClient) client).getBinder().getLinkCollection(
-            ((ODataClient) client).getDeserializer().toLinkCollection(input, format).getPayload());
+            ((ODataClient) client).getDeserializer(format).toLinkCollection(input).getPayload());
   }
 
   @Override
   @SuppressWarnings("unchecked")
-  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference) {
+  public <T> ResWrap<T> read(final InputStream src, final String format, final Class<T> reference)
+      throws ODataDeserializerException {
     if (ODataLinkCollection.class.isAssignableFrom(reference)) {
       final ResWrap<LinkCollection> container =
-              ((ODataClient) client).getDeserializer().toLinkCollection(src, ODataFormat.fromString(format));
+              ((ODataClient) client).getDeserializer(ODataFormat.fromString(format)).toLinkCollection(src);
 
       return new ResWrap<T>(
               container.getContextURL(),

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataSerializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataSerializerImpl.java
deleted file mode 100644
index 40b5b06..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataSerializerImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-package org.apache.olingo.client.core.op.impl.v3;
-
-import org.apache.olingo.commons.core.op.AbstractODataSerializer;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public class ODataSerializerImpl extends AbstractODataSerializer {
-
-  private static final long serialVersionUID = -8861908250297989806L;
-
-  public ODataSerializerImpl(final ODataServiceVersion version) {
-    super(version);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
index a23d2e8..0d3631a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.client.core.op.impl.v4;
 
 import java.net.URI;
+
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.data.ServiceDocumentItem;
 import org.apache.olingo.client.api.op.v4.ODataBinder;
@@ -69,24 +70,22 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.core.data.AnnotationImpl;
 import org.apache.olingo.commons.core.data.EnumValueImpl;
 import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.commons.core.domain.v4.ODataAnnotationImpl;
 import org.apache.olingo.commons.core.domain.v4.ODataDeletedEntityImpl;
 import org.apache.olingo.commons.core.domain.v4.ODataDeltaLinkImpl;
 import org.apache.olingo.commons.core.domain.v4.ODataPropertyImpl;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.apache.olingo.commons.core.op.ResourceFactory;
 
 public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder {
 
-  private static final long serialVersionUID = -6371110655960799393L;
-
   public ODataBinderImpl(final ODataClient client) {
     super(client);
   }
 
   @Override
   public void add(final ODataComplexValue<CommonODataProperty> complex, final CommonODataProperty property) {
-    complex.add((ODataProperty) property);
+    complex.add(property);
   }
 
   @Override
@@ -122,10 +121,9 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
     return serviceDocument;
   }
 
-  private void updateValuable(final Valuable propertyResource, final ODataValuable odataValuable,
-          final Class<? extends Entity> reference) {
+  private void updateValuable(final Valuable propertyResource, final ODataValuable odataValuable) {
 
-    propertyResource.setValue(getValue(odataValuable.getValue(), reference));
+    propertyResource.setValue(getValue(odataValuable.getValue()));
 
     if (odataValuable.hasPrimitiveValue()) {
       propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName());
@@ -138,62 +136,61 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
     }
   }
 
-  private void annotations(final ODataAnnotatable odataAnnotatable, final Annotatable annotatable,
-          final Class<? extends Entity> reference) {
+  private void annotations(final ODataAnnotatable odataAnnotatable, final Annotatable annotatable) {
 
     for (ODataAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) {
       final Annotation annotation = new AnnotationImpl();
 
       annotation.setTerm(odataAnnotation.getTerm());
       annotation.setType(odataAnnotation.getValue().getTypeName());
-      updateValuable(annotation, odataAnnotation, reference);
+      updateValuable(annotation, odataAnnotation);
 
       annotatable.getAnnotations().add(annotation);
     }
   }
 
   @Override
-  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet, final Class<? extends EntitySet> reference) {
-    final EntitySet entitySet = super.getEntitySet(odataEntitySet, reference);
+  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
+    final EntitySet entitySet = super.getEntitySet(odataEntitySet);
     entitySet.setDeltaLink(((ODataEntitySet) odataEntitySet).getDeltaLink());
-    annotations((ODataEntitySet) odataEntitySet, entitySet, ResourceFactory.entityClassForEntitySet(reference));
+    annotations((ODataEntitySet) odataEntitySet, entitySet);
     return entitySet;
   }
 
   @Override
-  protected void links(final ODataLinked odataLinked, final Linked linked, Class<? extends Entity> reference) {
-    super.links(odataLinked, linked, reference);
+  protected void links(final ODataLinked odataLinked, final Linked linked) {
+    super.links(odataLinked, linked);
 
     for (Link link : linked.getNavigationLinks()) {
       final org.apache.olingo.commons.api.domain.ODataLink odataLink = odataLinked.getNavigationLink(link.getTitle());
       if (!(odataLink instanceof ODataInlineEntity) && !(odataLink instanceof ODataInlineEntitySet)) {
-        annotations((ODataLink) odataLink, link, reference);
+        annotations((ODataLink) odataLink, link);
       }
     }
   }
 
   @Override
-  public Entity getEntity(final CommonODataEntity odataEntity, final Class<? extends Entity> reference) {
-    final Entity entity = super.getEntity(odataEntity, reference);
+  public Entity getEntity(final CommonODataEntity odataEntity) {
+    final Entity entity = super.getEntity(odataEntity);
     entity.setId(((ODataEntity) odataEntity).getId());
-    annotations((ODataEntity) odataEntity, entity, reference);
+    annotations((ODataEntity) odataEntity, entity);
     return entity;
   }
 
   @Override
-  public Property getProperty(final CommonODataProperty property, final Class<? extends Entity> reference) {
+  public Property getProperty(final CommonODataProperty property) {
     final ODataProperty _property = (ODataProperty) property;
 
-    final Property propertyResource = ResourceFactory.newProperty(reference);
+    final Property propertyResource = new PropertyImpl();
     propertyResource.setName(_property.getName());
-    updateValuable(propertyResource, _property, reference);
-    annotations(_property, propertyResource, reference);
+    updateValuable(propertyResource, _property);
+    annotations(_property, propertyResource);
 
     return propertyResource;
   }
 
   @Override
-  protected Value getValue(final ODataValue value, final Class<? extends Entity> reference) {
+  protected Value getValue(final ODataValue value) {
     Value valueResource;
     if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
             && ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isEnum()) {
@@ -201,7 +198,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
       valueResource = new EnumValueImpl(
               ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asEnum().getValue());
     } else {
-      valueResource = super.getValue(value, reference);
+      valueResource = super.getValue(value);
 
       if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
               && ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isLinkedComplex()) {
@@ -211,8 +208,8 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
 
         final ODataLinkedComplexValue linked =
                 ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asLinkedComplex();
-        annotations(linked, lcValueResource, reference);
-        links(linked, lcValueResource, reference);
+        annotations(linked, lcValueResource);
+        links(linked, lcValueResource);
 
         valueResource = lcValueResource;
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
index 0e0f72c..445db39 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataDeserializerImpl.java
@@ -20,28 +20,33 @@ package org.apache.olingo.client.core.op.impl.v4;
 
 import java.io.InputStream;
 
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata;
-import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.client.api.op.v4.ODataDeserializer;
-import org.apache.olingo.client.core.data.v4.JSONServiceDocumentImpl;
-import org.apache.olingo.client.core.data.v4.XMLServiceDocumentImpl;
+import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
+import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
 import org.apache.olingo.client.core.edm.xml.v4.EdmxImpl;
 import org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl;
 import org.apache.olingo.commons.api.data.Delta;
 import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.core.op.AbstractODataDeserializer;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.core.data.v4.AtomDeltaImpl;
-import org.apache.olingo.commons.core.data.v4.JSONDeltaImpl;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.AtomDeserializer;
+import org.apache.olingo.commons.core.data.JSONDeltaDeserializer;
+import org.apache.olingo.commons.core.op.AbstractODataDeserializer;
 
 public class ODataDeserializerImpl extends AbstractODataDeserializer implements ODataDeserializer {
 
-  private static final long serialVersionUID = 8593081342440470415L;
+  private final Format format;
 
-  public ODataDeserializerImpl(final ODataServiceVersion version) {
-    super(version);
+  public ODataDeserializerImpl(final ODataServiceVersion version, final Format format) {
+    super(version, format);
+    this.format = format;
   }
 
   @Override
@@ -54,18 +59,20 @@ public class ODataDeserializerImpl extends AbstractODataDeserializer implements
   }
 
   @Override
-  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input, final ODataFormat format) {
-    return format == ODataFormat.XML
-            ? this.<ServiceDocument, XMLServiceDocumentImpl>xml(input, XMLServiceDocumentImpl.class)
-            : this.<ServiceDocument, JSONServiceDocumentImpl>json(input, JSONServiceDocumentImpl.class);
-
+  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) throws ODataDeserializerException {
+    return format == ODataFormat.XML ?
+        new XMLServiceDocumentDeserializer(version, false).toServiceDocument(input) :
+        new JSONServiceDocumentDeserializer(version, false).toServiceDocument(input);
   }
 
   @Override
-  public ResWrap<Delta> toDelta(final InputStream input, final ODataPubFormat format) {
-    return format == ODataPubFormat.ATOM
-            ? this.<Delta, AtomDeltaImpl>atom(input, AtomDeltaImpl.class)
-            : this.<Delta, JSONDeltaImpl>json(input, JSONDeltaImpl.class);
+  public ResWrap<Delta> toDelta(final InputStream input) throws ODataDeserializerException {
+    try {
+      return format == ODataPubFormat.ATOM ?
+          new AtomDeserializer(version).delta(input) :
+          new JSONDeltaDeserializer(version, false).toDelta(input);
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    }
   }
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
index 71c2244..ce146e5 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.client.core.op.impl.v4;
 
 import java.io.InputStream;
+
 import org.apache.olingo.client.api.op.v4.ODataReader;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.op.AbstractODataReader;
@@ -27,27 +28,29 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.v4.ODataProperty;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
 
 public class ODataReaderImpl extends AbstractODataReader implements ODataReader {
 
-  private static final long serialVersionUID = -2481293269536406956L;
-
   public ODataReaderImpl(final ODataClient client) {
     super(client);
   }
 
   @Override
-  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
-    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer().toEntitySet(input, format));
+  public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
   }
 
   @Override
-  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
-    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer().toEntity(input, format));
+  public ODataEntity readEntity(final InputStream input, final ODataPubFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
   }
 
   @Override
-  public ODataProperty readProperty(final InputStream input, final ODataFormat format) {
-    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer().toProperty(input, format));
+  public ODataProperty readProperty(final InputStream input, final ODataFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) client).getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataSerializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataSerializerImpl.java
deleted file mode 100644
index f75fb3e..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataSerializerImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-package org.apache.olingo.client.core.op.impl.v4;
-
-import org.apache.olingo.commons.core.op.AbstractODataSerializer;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public class ODataSerializerImpl extends AbstractODataSerializer {
-
-  private static final long serialVersionUID = 7587265188399685309L;
-
-  public ODataSerializerImpl(final ODataServiceVersion version) {
-    super(version);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
index 8d696ec..2042a9a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java
@@ -18,8 +18,6 @@
  */
 package org.apache.olingo.client.core.v3;
 
-import org.apache.olingo.client.api.v3.ODataClient;
-import org.apache.olingo.client.api.v3.Configuration;
 import org.apache.olingo.client.api.communication.header.HeaderName;
 import org.apache.olingo.client.api.communication.header.ODataHeaders;
 import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory;
@@ -27,12 +25,13 @@ import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFacto
 import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType;
 import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
 import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory;
-import org.apache.olingo.commons.api.op.ODataSerializer;
-import org.apache.olingo.client.api.op.v3.ODataDeserializer;
 import org.apache.olingo.client.api.op.v3.ODataBinder;
+import org.apache.olingo.client.api.op.v3.ODataDeserializer;
 import org.apache.olingo.client.api.op.v3.ODataReader;
-import org.apache.olingo.client.api.uri.v3.URIBuilder;
 import org.apache.olingo.client.api.uri.v3.FilterFactory;
+import org.apache.olingo.client.api.uri.v3.URIBuilder;
+import org.apache.olingo.client.api.v3.Configuration;
+import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.client.core.AbstractODataClient;
 import org.apache.olingo.client.core.communication.header.ODataHeadersImpl;
 import org.apache.olingo.client.core.communication.request.batch.v3.BatchRequestFactoryImpl;
@@ -42,25 +41,24 @@ import org.apache.olingo.client.core.communication.request.retrieve.v3.RetrieveR
 import org.apache.olingo.client.core.op.impl.v3.ODataBinderImpl;
 import org.apache.olingo.client.core.op.impl.v3.ODataDeserializerImpl;
 import org.apache.olingo.client.core.op.impl.v3.ODataReaderImpl;
-import org.apache.olingo.client.core.op.impl.v3.ODataSerializerImpl;
-import org.apache.olingo.client.core.uri.v3.URIBuilderImpl;
 import org.apache.olingo.client.core.uri.v3.FilterFactoryImpl;
+import org.apache.olingo.client.core.uri.v3.URIBuilderImpl;
 import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.op.ODataSerializer;
+import org.apache.olingo.commons.core.data.AtomSerializer;
+import org.apache.olingo.commons.core.data.JsonSerializer;
 import org.apache.olingo.commons.core.domain.v3.ODataObjectFactoryImpl;
 
 public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
 
-  private static final long serialVersionUID = -1655712193243609209L;
-
   protected final Configuration configuration = new ConfigurationImpl();
 
   private final FilterFactory filterFactory = new FilterFactoryImpl(getServiceVersion());
 
-  private final ODataDeserializer deserializer = new ODataDeserializerImpl(getServiceVersion());
-
-  private final ODataSerializer serializer = new ODataSerializerImpl(getServiceVersion());
-
   private final ODataReader reader = new ODataReaderImpl(this);
 
   private final ODataBinder binder = new ODataBinderImpl(this);
@@ -105,13 +103,15 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
   }
 
   @Override
-  public ODataDeserializer getDeserializer() {
-    return deserializer;
+  public ODataDeserializer getDeserializer(final Format format) {
+    return new ODataDeserializerImpl(getServiceVersion(), format);
   }
 
   @Override
-  public ODataSerializer getSerializer() {
-    return serializer;
+  public ODataSerializer getSerializer(final Format format) {
+    return format instanceof ODataPubFormat && format == ODataPubFormat.ATOM
+        || format instanceof ODataFormat && format == ODataFormat.XML ?
+        new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false);
   }
 
   @Override
@@ -134,7 +134,6 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
     return retrieveReqFact;
   }
 
-  @SuppressWarnings("unchecked")
   @Override
   public CUDRequestFactory getCUDRequestFactory() {
     return cudReqFact;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
index 4b4efd4..9f38353 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java
@@ -18,8 +18,6 @@
  */
 package org.apache.olingo.client.core.v4;
 
-import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.api.v4.Configuration;
 import org.apache.olingo.client.api.communication.header.HeaderName;
 import org.apache.olingo.client.api.communication.header.ODataHeaders;
 import org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory;
@@ -28,13 +26,14 @@ import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
 import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory;
 import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory;
 import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory;
-import org.apache.olingo.commons.api.op.ODataSerializer;
 import org.apache.olingo.client.api.op.v4.ODataBinder;
 import org.apache.olingo.client.api.op.v4.ODataDeserializer;
 import org.apache.olingo.client.api.op.v4.ODataReader;
-import org.apache.olingo.client.api.uri.v4.URIBuilder;
 import org.apache.olingo.client.api.uri.v4.FilterFactory;
 import org.apache.olingo.client.api.uri.v4.SearchFactory;
+import org.apache.olingo.client.api.uri.v4.URIBuilder;
+import org.apache.olingo.client.api.v4.Configuration;
+import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.AbstractODataClient;
 import org.apache.olingo.client.core.communication.header.ODataHeadersImpl;
 import org.apache.olingo.client.core.communication.request.batch.v4.BatchRequestFactoryImpl;
@@ -45,27 +44,26 @@ import org.apache.olingo.client.core.communication.request.v4.AsyncRequestFactor
 import org.apache.olingo.client.core.op.impl.v4.ODataBinderImpl;
 import org.apache.olingo.client.core.op.impl.v4.ODataDeserializerImpl;
 import org.apache.olingo.client.core.op.impl.v4.ODataReaderImpl;
-import org.apache.olingo.client.core.op.impl.v4.ODataSerializerImpl;
-import org.apache.olingo.client.core.uri.v4.URIBuilderImpl;
 import org.apache.olingo.client.core.uri.v4.FilterFactoryImpl;
+import org.apache.olingo.client.core.uri.v4.URIBuilderImpl;
 import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.Format;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.commons.api.op.ODataSerializer;
+import org.apache.olingo.commons.core.data.AtomSerializer;
+import org.apache.olingo.commons.core.data.JsonSerializer;
 import org.apache.olingo.commons.core.domain.v4.ODataObjectFactoryImpl;
 
 public class ODataClientImpl extends AbstractODataClient<UpdateType> implements ODataClient {
 
-  private static final long serialVersionUID = -6653176125573631964L;
-
   protected final Configuration configuration = new ConfigurationImpl();
 
   private final FilterFactory filterFactory = new FilterFactoryImpl(getServiceVersion());
 
   private final SearchFactory searchFactory = new SearchFactoryImpl();
 
-  private final ODataDeserializer deserializer = new ODataDeserializerImpl(getServiceVersion());
-
-  private final ODataSerializer serializer = new ODataSerializerImpl(getServiceVersion());
-
   private final ODataReader reader = new ODataReaderImpl(this);
 
   private final ODataBinder binder = new ODataBinderImpl(this);
@@ -116,13 +114,15 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
   }
 
   @Override
-  public ODataDeserializer getDeserializer() {
-    return deserializer;
+  public ODataDeserializer getDeserializer(final Format format) {
+    return new ODataDeserializerImpl(getServiceVersion(), format);
   }
 
   @Override
-  public ODataSerializer getSerializer() {
-    return serializer;
+  public ODataSerializer getSerializer(final Format format) {
+    return format instanceof ODataPubFormat && format == ODataPubFormat.ATOM
+        || format instanceof ODataFormat && format == ODataFormat.XML ?
+        new AtomSerializer(getServiceVersion()) : new JsonSerializer(getServiceVersion(), false);
   }
 
   @Override
@@ -150,7 +150,6 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements
     return retrieveReqFact;
   }
 
-  @SuppressWarnings("unchecked")
   @Override
   public CUDRequestFactory getCUDRequestFactory() {
     return cudReqFact;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
index 1b047a8..2fcdb4c 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/AtomTest.java
@@ -69,10 +69,10 @@ public class AtomTest extends AbstractTest {
 
   protected void entitySet(final String filename, final ODataPubFormat format) throws Exception {
     final StringWriter writer = new StringWriter();
-    getClient().getSerializer().entitySet(getClient().getDeserializer().toEntitySet(
-            getClass().getResourceAsStream("Customer." + getSuffix(format)), format).getPayload(), writer);
+    getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntitySet(
+        getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
 
-    assertSimilar("Customer." + getSuffix(format), writer.toString());
+    assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }
 
   @Test
@@ -82,8 +82,8 @@ public class AtomTest extends AbstractTest {
 
   protected void entity(final String filename, final ODataPubFormat format) throws Exception {
     final StringWriter writer = new StringWriter();
-    getClient().getSerializer().entity(getClient().getDeserializer().toEntity(
-            getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(), writer);
+    getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toEntity(
+        getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
 
     assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }
@@ -102,9 +102,8 @@ public class AtomTest extends AbstractTest {
 
   protected void property(final String filename, final ODataFormat format) throws Exception {
     final StringWriter writer = new StringWriter();
-    getClient().getSerializer().property(getClient().getDeserializer().
-            toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(format)), format).getPayload(),
-            writer);
+    getClient().getSerializer(format).write(writer, getClient().getDeserializer(format).toProperty(
+        getClass().getResourceAsStream(filename + "." + getSuffix(format))).getPayload());
 
     assertSimilar(filename + "." + getSuffix(format), writer.toString());
   }