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

[10/21] [OLINGO-317] Finished DeSerializer refactoring

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
index 67ab03b..1e2930f 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeletedEntityImpl.java
@@ -23,10 +23,7 @@ import org.apache.olingo.commons.api.data.DeletedEntity;
 
 public class DeletedEntityImpl extends AbstractAnnotatedObject implements DeletedEntity {
 
-  private static final long serialVersionUID = 2075093398299488510L;
-
   private URI id;
-
   private Reason reason;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
index 0834b55..7ed1de6 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/DeltaLinkImpl.java
@@ -23,12 +23,8 @@ import org.apache.olingo.commons.api.data.DeltaLink;
 
 public class DeltaLinkImpl extends AbstractAnnotatedObject implements DeltaLink {
 
-  private static final long serialVersionUID = 581329273399308799L;
-
   private URI source;
-
   private String relationship;
-
   private URI target;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
index 28451a9..003c72d 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntityImpl.java
@@ -31,20 +31,15 @@ import org.apache.olingo.commons.api.domain.ODataOperation;
  */
 public class EntityImpl extends AbstractODataObject implements Entity {
 
-  private static final long serialVersionUID = 2127764552600969783L;
-
   private String eTag;
 
   private String type;
 
   private Link readLink;
-
   private Link editLink;
 
   private final List<Link> associationLinks = new ArrayList<Link>();
-
   private final List<Link> navigationLinks = new ArrayList<Link>();
-
   private final List<Link> mediaEditLinks = new ArrayList<Link>();
 
   private final List<ODataOperation> operations = new ArrayList<ODataOperation>();
@@ -52,9 +47,7 @@ public class EntityImpl extends AbstractODataObject implements Entity {
   private final List<Property> properties = new ArrayList<Property>();
 
   private URI mediaContentSource;
-
   private String mediaContentType;
-
   private String mediaETag;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
index 1920809..3a985b4 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/EntitySetImpl.java
@@ -26,8 +26,6 @@ import org.apache.olingo.commons.api.data.EntitySet;
 
 public class EntitySetImpl extends AbstractODataObject implements EntitySet {
 
-  private static final long serialVersionUID = -9159884750819150969L;
-
   private Integer count;
 
   private final List<Entity> entities = new ArrayList<Entity>();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONLinkCollectionDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONLinkCollectionDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONLinkCollectionDeserializer.java
new file mode 100755
index 0000000..1876b9c
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONLinkCollectionDeserializer.java
@@ -0,0 +1,80 @@
+/*
+ * 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.commons.core.data;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.core.data.v3.LinkCollectionImpl;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JSONLinkCollectionDeserializer extends JsonDeserializer {
+
+  public JSONLinkCollectionDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
+
+  protected ResWrap<LinkCollection> doDeserialize(final JsonParser parser) throws IOException {
+
+    final ObjectNode tree = parser.getCodec().readTree(parser);
+
+    final LinkCollectionImpl links = new LinkCollectionImpl();
+
+    if (tree.hasNonNull("odata.metadata")) {
+      links.setMetadata(URI.create(tree.get("odata.metadata").textValue()));
+    }
+
+    if (tree.hasNonNull(Constants.JSON_URL)) {
+      links.getLinks().add(URI.create(tree.get(Constants.JSON_URL).textValue()));
+    }
+
+    if (tree.hasNonNull(Constants.VALUE)) {
+      for (final JsonNode item : tree.get(Constants.VALUE)) {
+        final URI uri = URI.create(item.get(Constants.JSON_URL).textValue());
+        links.getLinks().add(uri);
+      }
+    }
+
+    if (tree.hasNonNull(jsonNextLink)) {
+      links.setNext(URI.create(tree.get(jsonNextLink).textValue()));
+    }
+
+    return new ResWrap<LinkCollection>((URI) null, null, links);
+  }
+
+  public ResWrap<LinkCollection> toLinkCollection(InputStream input) throws ODataDeserializerException {
+    try {
+      JsonParser parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
index e067d88..bf1c19e 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
@@ -102,7 +102,7 @@ public class JsonSerializer implements ODataSerializer {
       } else if (obj instanceof Entity) {
         new JSONEntitySerializer(version, serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
       } else if (obj instanceof Property) {
-        new JSONPropertySerializer(version, serverMode).doSerialize((Property) obj, json);
+        new JSONPropertySerializer(version, serverMode).doContainerSerialize((ResWrap<Property>) container, json);
       } else if (obj instanceof Link) {
         link((Link) obj, json);
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
index 85acc8f..72e09cf 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
@@ -24,20 +24,12 @@ import org.apache.olingo.commons.api.data.Link;
 
 public class LinkImpl extends AbstractAnnotatedObject implements Link {
 
-  private static final long serialVersionUID = -3449344217160035501L;
-
   private String title;
-
   private String rel;
-
   private String href;
-
   private String type;
-
   private String mediaETag;
-
   private Entity entity;
-
   private EntitySet entitySet;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
index 9d9f35c..f98e854 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
@@ -23,12 +23,8 @@ import org.apache.olingo.commons.api.data.Value;
 
 public class PropertyImpl extends AbstractAnnotatedObject implements Property {
 
-  private static final long serialVersionUID = -7175704800169997060L;
-
   private String name;
-
   private String type;
-
   private Value value;
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
deleted file mode 100644
index edf871b..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
+++ /dev/null
@@ -1,118 +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.commons.core.data.v3;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.olingo.commons.api.data.v3.LinkCollection;
-import org.apache.olingo.commons.core.data.AbstractPayloadObject;
-
-/**
- * Link from an entity, represented via JSON.
- */
-public class JSONLinkCollectionImpl extends AbstractPayloadObject implements LinkCollection {
-
-  private static final long serialVersionUID = -5006368367235783907L;
-
-  /**
-   * JSON link URL representation.
-   */
-  static class JSONLinkURL extends AbstractPayloadObject {
-
-    private static final long serialVersionUID = 5365055617973271468L;
-
-    private URI url;
-
-    public URI getUrl() {
-      return url;
-    }
-
-    public void setUrl(final URI url) {
-      this.url = url;
-    }
-  }
-
-  @JsonProperty(value = "odata.metadata", required = false)
-  private URI metadata;
-
-  @JsonProperty(required = false)
-  private URI url;
-
-  @JsonProperty(value = "value", required = false)
-  private final List<JSONLinkURL> links = new ArrayList<JSONLinkURL>();
-
-  @JsonProperty(value = "odata.nextLink", required = false)
-  private String next;
-
-  /**
-   * Gets the metadata URI.
-   */
-  public URI getMetadata() {
-    return metadata;
-  }
-
-  /**
-   * Sets the metadata URI.
-   *
-   * @param metadata metadata URI.
-   */
-  public void setMetadata(final URI metadata) {
-    this.metadata = metadata;
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @JsonIgnore
-  @Override
-  public List<URI> getLinks() {
-    final List<URI> result = new ArrayList<URI>();
-
-    if (this.url == null) {
-      for (JSONLinkURL link : links) {
-        result.add(link.getUrl());
-      }
-    } else {
-      result.add(this.url);
-    }
-
-    return result;
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @JsonIgnore
-  @Override
-  public void setNext(final URI next) {
-    this.next = next == null ? null : next.toASCIIString();
-  }
-
-  /**
-   * {@inheritDoc }
-   */
-  @JsonIgnore
-  @Override
-  public URI getNext() {
-    return next == null ? null : URI.create(next);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
index 3310723..f62b423 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/LinkCollectionImpl.java
@@ -21,9 +21,11 @@ package org.apache.olingo.commons.core.data.v3;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
+
 import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.core.data.AbstractAnnotatedObject;
 
-public class LinkCollectionImpl implements LinkCollection {
+public class LinkCollectionImpl extends AbstractAnnotatedObject implements LinkCollection {
 
   private final List<URI> links = new ArrayList<URI>();
   private URI next;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
index 021a77d..d507ebe 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v4/DeltaImpl.java
@@ -27,12 +27,8 @@ import org.apache.olingo.commons.core.data.EntitySetImpl;
 
 public class DeltaImpl extends EntitySetImpl implements Delta {
 
-  private static final long serialVersionUID = 4576771708961553195L;
-
   private final List<DeletedEntity> deletedEntities = new ArrayList<DeletedEntity>();
-
   private final List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
-
   private final List<DeltaLink> deletedLinks = new ArrayList<DeltaLink>();
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
index a2ef134..548d79d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/op/AbstractODataDeserializer.java
@@ -51,12 +51,12 @@ public abstract class AbstractODataDeserializer {
   protected final ODataServiceVersion version;
   protected final ODataDeserializer deserializer;
 
-  public AbstractODataDeserializer(final ODataServiceVersion version, final Format format) {
+  public AbstractODataDeserializer(final ODataServiceVersion version, final boolean serverMode, final Format format) {
     this.version = version;
     if (format == ODataFormat.XML || format == ODataPubFormat.ATOM) {
       deserializer = new AtomDeserializer(version);
     } else {
-      deserializer = new JsonDeserializer(version, false);
+      deserializer = new JsonDeserializer(version, serverMode);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
index cf9f3f3..acea9f5 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
@@ -18,52 +18,26 @@
  */
 package org.apache.olingo.server.core;
 
-import java.io.IOException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
 import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.data.ContextURL;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpContentType;
-import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.api.http.HttpHeader;
-import org.apache.olingo.commons.core.data.EntityImpl;
-import org.apache.olingo.commons.core.data.EntitySetImpl;
-import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
-import org.apache.olingo.commons.core.op.InjectableSerializerProvider;
+import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.processor.DefaultProcessor;
-import org.apache.olingo.server.api.processor.EntityProcessor;
-import org.apache.olingo.server.api.processor.EntitySetProcessor;
-import org.apache.olingo.server.api.processor.MetadataProcessor;
-import org.apache.olingo.server.api.processor.Processor;
-import org.apache.olingo.server.api.processor.ServiceDocumentProcessor;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.processor.*;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
 import org.apache.olingo.server.api.uri.UriResourcePartTyped;
-import org.apache.olingo.server.core.serializer.utils.CircleStreamBuffer;
 import org.apache.olingo.server.core.uri.parser.Parser;
 import org.apache.olingo.server.core.uri.validator.UriValidator;
 
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.InjectableValues;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 public class ODataHandler {
 
@@ -134,39 +108,6 @@ public class ODataHandler {
     UriResource lastPathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex);
     switch (lastPathSegment.getKind()) {
     case entitySet:
-      long time = System.nanoTime();
-      ResWrap<EntitySet> wrap = new ResWrap<EntitySet>(
-          ContextURL.getInstance(URI.create("dummyContextURL")), "dummyMetadataETag",
-          createEntitySet());
-      System.out.println((System.nanoTime() - time) / 1000 + " microseconds");
-      time = System.nanoTime();
-      CircleStreamBuffer buffer = new CircleStreamBuffer();
-      if (false) {
-        ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(Include.NON_NULL);
-        mapper.setInjectableValues(new InjectableValues.Std()
-            .addValue(ODataServiceVersion.class, ODataServiceVersion.V40)
-            .addValue(Boolean.class, Boolean.TRUE));
-        mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
-            mapper.getSerializationConfig()
-                .withAttribute(ODataServiceVersion.class, ODataServiceVersion.V40)
-                .withAttribute(Boolean.class, Boolean.TRUE),
-            mapper.getSerializerFactory()));
-        try {
-          mapper.writeValue(buffer.getOutputStream(), wrap);
-        } catch (final IOException e) {}
-        response.setContent(buffer.getInputStream());
-      } else {
-        ODataSerializer serializer = odata.createSerializer(org.apache.olingo.server.api.serializer.ODataFormat.JSON);
-        response.setContent(serializer.entitySet(
-            edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
-                .getEntitySet("ESAllPrim"),
-            wrap.getPayload(),
-            ContextURL.getInstance(URI.create("dummyContextURL"))));
-      }
-      System.out.println((System.nanoTime() - time) / 1000 + " microseconds");
-      response.setStatusCode(200);
-      response.setHeader("Content-Type", ContentType.APPLICATION_JSON);
-
       if (((UriResourcePartTyped) lastPathSegment).isCollection()) {
         if (request.getMethod().equals(HttpMethod.GET)) {
           EntitySetProcessor esp = selectProcessor(EntitySetProcessor.class);
@@ -240,34 +181,4 @@ public class ODataHandler {
       }
     }
   }
-
-  protected Entity createEntity() {
-    Entity entity = new EntityImpl();
-    Property property = new PropertyImpl();
-    property.setName("PropertyString");
-    property.setType("String"); //"dummyType");
-    property.setValue(new PrimitiveValueImpl("dummyValue"));
-    entity.getProperties().add(property);
-    Property propertyInt = new PropertyImpl();
-    propertyInt.setName("PropertyInt16");
-    // propertyInt.setType("Edm.Int32");
-    propertyInt.setValue(new PrimitiveValueImpl("042"));
-    entity.getProperties().add(propertyInt);
-    Property propertyGuid = new PropertyImpl();
-    propertyGuid.setName("PropertyGuid");
-    propertyGuid.setType("Edm.Guid");
-    propertyGuid.setValue(new PrimitiveValueImpl(UUID.randomUUID().toString()));
-    entity.getProperties().add(propertyGuid);
-    return entity;
-  }
-
-  protected EntitySet createEntitySet() {
-    EntitySet entitySet = new EntitySetImpl();
-    entitySet.setCount(4242);
-    entitySet.setNext(URI.create("nextLinkURI"));
-    for (int i = 0; i < 1000; i++) {
-      entitySet.getEntities().add(createEntity());
-    }
-    return entitySet;
-  }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/server-tecsvc/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/pom.xml b/lib/server-tecsvc/pom.xml
index 1371a00..3925fbd 100644
--- a/lib/server-tecsvc/pom.xml
+++ b/lib/server-tecsvc/pom.xml
@@ -122,6 +122,17 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>olingo-commons-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>olingo-commons-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
       <scope>runtime</scope>
@@ -140,6 +151,11 @@
       <artifactId>commons-io</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.olingo</groupId>
+      <artifactId>core</artifactId>
+      <version>0.1.0-SNAPSHOT</version>
+    </dependency>
   </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
index ec8a061..9841dd8 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
@@ -29,6 +29,7 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.server.api.ODataHttpHandler;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.tecsvc.data.DataProvider;
+import org.apache.olingo.server.tecsvc.processor.SampleJsonProcessor;
 import org.apache.olingo.server.tecsvc.processor.TechnicalProcessor;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.slf4j.Logger;
@@ -56,8 +57,9 @@ public class TechnicalServlet extends HttpServlet {
 
     ODataHttpHandler handler = odata.createHandler(edm);
     
-    handler.register(new TechnicalProcessor(dataProvider));
-       
+//    handler.register(new TechnicalProcessor(dataProvider));
+    handler.register(new SampleJsonProcessor());
+
     handler.process(req, resp);
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/70afb2ac/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
new file mode 100644
index 0000000..66e863b
--- /dev/null
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/SampleJsonProcessor.java
@@ -0,0 +1,126 @@
+/*
+ * 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.server.tecsvc.processor;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.core.data.EntityImpl;
+import org.apache.olingo.commons.core.data.EntitySetImpl;
+import org.apache.olingo.commons.core.data.PrimitiveValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.processor.EntityProcessor;
+import org.apache.olingo.server.api.processor.EntitySetProcessor;
+import org.apache.olingo.server.api.serializer.ODataFormat;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URI;
+import java.util.UUID;
+
+public class SampleJsonProcessor implements EntitySetProcessor, EntityProcessor {
+    private static final Logger LOG = LoggerFactory.getLogger(SampleJsonProcessor.class);
+
+    private OData odata;
+    private Edm edm;
+
+    @Override
+    public void init(OData odata, Edm edm) {
+      this.odata = odata;
+      this.edm = edm;
+    }
+
+    @Override
+    public void readEntitySet(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+      long time = System.nanoTime();
+
+      EntitySet entitySet = createEntitySet();
+
+      LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
+      time = System.nanoTime();
+      ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
+      response.setContent(serializer.entitySet(
+              edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+                      .getEntitySet("ESAllPrim"),
+              entitySet,
+              ContextURL.getInstance(URI.create("dummyContextURL"))));
+      LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
+
+      response.setStatusCode(200);
+      response.setHeader("Content-Type", ContentType.APPLICATION_JSON);
+    }
+
+    @Override
+    public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+      long time = System.nanoTime();
+      Entity entity = createEntity();
+
+      LOG.info((System.nanoTime() - time) / 1000 + " microseconds");
+      time = System.nanoTime();
+      ODataSerializer serializer = odata.createSerializer(ODataFormat.JSON);
+      response.setContent(serializer.entity(
+              edm.getEntityContainer(new FullQualifiedName("com.sap.odata.test1", "Container"))
+                      .getEntitySet("ESAllPrim").getEntityType(),
+              entity,
+              ContextURL.getInstance(URI.create("dummyContextURL"))));
+      LOG.info("Finished in " + (System.nanoTime() - time) / 1000 + " microseconds");
+
+      response.setStatusCode(200);
+      response.setHeader("Content-Type", ContentType.APPLICATION_JSON);
+    }
+
+    protected Entity createEntity() {
+      Entity entity = new EntityImpl();
+      Property property = new PropertyImpl();
+      property.setName("PropertyString");
+      property.setType("String"); //"dummyType");
+      property.setValue(new PrimitiveValueImpl("dummyValue"));
+      entity.getProperties().add(property);
+      Property propertyInt = new PropertyImpl();
+      propertyInt.setName("PropertyInt16");
+      // propertyInt.setType("Edm.Int32");
+      propertyInt.setValue(new PrimitiveValueImpl("42"));
+      entity.getProperties().add(propertyInt);
+      Property propertyGuid = new PropertyImpl();
+      propertyGuid.setName("PropertyGuid");
+      propertyGuid.setType("Edm.Guid");
+      propertyGuid.setValue(new PrimitiveValueImpl(UUID.randomUUID().toString()));
+      entity.getProperties().add(propertyGuid);
+      return entity;
+    }
+
+    protected EntitySet createEntitySet() {
+      EntitySet entitySet = new EntitySetImpl();
+      entitySet.setCount(4242);
+      entitySet.setNext(URI.create("nextLinkURI"));
+      for (int i = 0; i < 1000; i++) {
+        entitySet.getEntities().add(createEntity());
+      }
+      return entitySet;
+    }
+  }