You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/05/10 10:26:44 UTC

[02/10] git commit: Cleanings

Cleanings


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/40895b8b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/40895b8b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/40895b8b

Branch: refs/heads/master
Commit: 40895b8b2db9ec20d3aa2618937020ffd548a496
Parents: b497634
Author: Francesco Chicchiriccò <--global>
Authored: Fri May 9 12:46:19 2014 +0200
Committer: Francesco Chicchiriccò <--global>
Committed: Fri May 9 12:46:19 2014 +0200

----------------------------------------------------------------------
 .../ext/proxy/EntityContainerFactory.java       |  14 +-
 .../olingo/ext/proxy/api/AbstractContainer.java |  32 --
 .../apache/olingo/ext/proxy/api/Container.java  |  32 ++
 .../commons/AbstractInvocationHandler.java      |   2 +-
 .../olingo/ext/proxy/commons/Container.java     | 544 ------------------
 .../olingo/ext/proxy/commons/ContainerImpl.java | 548 +++++++++++++++++++
 .../EntityContainerInvocationHandler.java       |  13 +-
 .../olingo/ext/proxy/utils/ClassUtils.java      |   3 +-
 .../olingo/ext/proxy/utils/EngineUtils.java     |   7 +-
 ext/pojogen-maven-plugin/pom.xml                |   2 +-
 .../src/it/actionOverloadingService/pom.xml     |  92 ----
 .../it/actionOverloadingService/verify.groovy   |  20 -
 .../src/it/defaultService/pom.xml               |  92 ----
 .../src/it/defaultService/verify.groovy         |  20 -
 .../src/it/keyAsSegmentService/pom.xml          |  92 ----
 .../src/it/keyAsSegmentService/verify.groovy    |  20 -
 .../src/it/northwind/pom.xml                    |  92 ----
 .../src/it/northwind/verify.groovy              |  20 -
 .../src/it/odataWriterDefaultService/pom.xml    |  92 ----
 .../it/odataWriterDefaultService/verify.groovy  |  20 -
 .../src/it/openTypeService/pom.xml              |  92 ----
 .../src/it/openTypeService/verify.groovy        |  20 -
 .../src/it/primitiveKeysService/pom.xml         |  92 ----
 .../src/it/primitiveKeysService/verify.groovy   |  20 -
 .../src/it/staticServiceV3/pom.xml              |  92 ----
 .../src/it/staticServiceV3/verify.groovy        |  20 -
 .../src/it/staticServiceV4/pom.xml              |  92 ----
 .../src/it/staticServiceV4/verify.groovy        |  20 -
 .../olingo/fit/proxy/v3/AbstractTest.java       |   2 +-
 .../astoriadefaultservice/DefaultContainer.java |   4 +-
 .../olingo/fit/proxy/v4/AbstractTest.java       |   2 +-
 .../odatawcfservice/InMemoryEntities.java       |   4 +-
 32 files changed, 606 insertions(+), 1611 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
index 4d70364..9c58600 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/EntityContainerFactory.java
@@ -31,7 +31,7 @@ import org.apache.olingo.ext.proxy.context.Context;
 /**
  * Entry point for ODataJClient proxy mode, gives access to entity container instances.
  */
-public class EntityContainerFactory {
+public final class EntityContainerFactory {
 
   private static final Object MONITOR = new Object();
 
@@ -40,8 +40,7 @@ public class EntityContainerFactory {
   private static final Map<String, EntityContainerFactory> FACTORY_PER_SERVICEROOT =
           new ConcurrentHashMap<String, EntityContainerFactory>();
 
-  private static final Map<Class<?>, Object> ENTITY_CONTAINERS =
-          new ConcurrentHashMap<Class<?>, Object>();
+  private static final Map<Class<?>, Object> ENTITY_CONTAINERS = new ConcurrentHashMap<Class<?>, Object>();
 
   private final CommonEdmEnabledODataClient<?> client;
 
@@ -59,6 +58,7 @@ public class EntityContainerFactory {
 
   private static <C extends CommonEdmEnabledODataClient<?>> EntityContainerFactory getInstance(
           final C client, final String serviceRoot) {
+
     if (!FACTORY_PER_SERVICEROOT.containsKey(serviceRoot)) {
       final EntityContainerFactory instance = new EntityContainerFactory(client, serviceRoot);
       FACTORY_PER_SERVICEROOT.put(serviceRoot, instance);
@@ -67,11 +67,11 @@ public class EntityContainerFactory {
     return FACTORY_PER_SERVICEROOT.get(serviceRoot);
   }
 
-  public static EntityContainerFactory getV3Instance(final String serviceRoot) {
+  public static EntityContainerFactory getV3(final String serviceRoot) {
     return getInstance(ODataClientFactory.getEdmEnabledV3(serviceRoot), serviceRoot);
   }
 
-  public static EntityContainerFactory getV4Instance(final String serviceRoot) {
+  public static EntityContainerFactory getV4(final String serviceRoot) {
     return getInstance(ODataClientFactory.getEdmEnabledV4(serviceRoot), serviceRoot);
   }
 
@@ -92,9 +92,7 @@ public class EntityContainerFactory {
    * @return an initialized concrete implementation of the passed reference
    * @throws IllegalStateException if <tt>serviceRoot</tt> was not set
    * @throws IllegalArgumentException if the passed reference is not an interface annotated as EntityContainer
-   * @see com.msopentech.odatajclient.proxy.api.annotations.EntityContainer
    */
-  @SuppressWarnings("unchecked")
   public <T> T getEntityContainer(final Class<T> reference) throws IllegalStateException, IllegalArgumentException {
     if (StringUtils.isBlank(serviceRoot)) {
       throw new IllegalStateException("serviceRoot was not set");
@@ -107,6 +105,6 @@ public class EntityContainerFactory {
               EntityContainerInvocationHandler.getInstance(client, reference, this));
       ENTITY_CONTAINERS.put(reference, entityContainer);
     }
-    return (T) ENTITY_CONTAINERS.get(reference);
+    return reference.cast(ENTITY_CONTAINERS.get(reference));
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractContainer.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractContainer.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractContainer.java
deleted file mode 100644
index e062f02..0000000
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractContainer.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.ext.proxy.api;
-
-import java.io.Serializable;
-
-/**
- * Interface for container operations.
- */
-public abstract interface AbstractContainer extends Serializable {
-
-  /**
-   * Flushes all pending changes to the OData service.
-   */
-  void flush();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Container.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Container.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Container.java
new file mode 100644
index 0000000..b95b341
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Container.java
@@ -0,0 +1,32 @@
+/*
+ * 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.ext.proxy.api;
+
+import java.io.Serializable;
+
+/**
+ * Interface for container operations.
+ */
+public interface Container extends Serializable {
+
+  /**
+   * Flushes all pending changes to the OData service.
+   */
+  void flush();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
index 7c74ac3..5b031f2 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
@@ -179,7 +179,7 @@ abstract class AbstractInvocationHandler<C extends CommonEdmEnabledODataClient<?
 
     // 2. IMPORTANT: flush any pending change *before* invoke if this operation is side effecting
     if (annotation.type() == OperationType.ACTION) {
-      new Container(client, containerHandler.getFactory()).flush();
+      new ContainerImpl(client, containerHandler.getFactory()).flush();
     }
 
     // 3. invoke

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/Container.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/Container.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/Container.java
deleted file mode 100644
index 8b4422b..0000000
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/Container.java
+++ /dev/null
@@ -1,544 +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.ext.proxy.commons;
-
-import java.io.InputStream;
-import java.lang.reflect.Proxy;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
-import org.apache.olingo.client.api.communication.header.ODataPreferences;
-import org.apache.olingo.client.api.communication.request.ODataStreamedRequest;
-import org.apache.olingo.client.api.communication.request.batch.BatchStreamManager;
-import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest;
-import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
-import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
-import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
-import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
-import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
-import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest;
-import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
-import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
-import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
-import org.apache.olingo.client.api.communication.response.ODataResponse;
-import org.apache.olingo.client.api.uri.CommonURIBuilder;
-import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ODataMediaFormat;
-import org.apache.olingo.ext.proxy.EntityContainerFactory;
-import org.apache.olingo.ext.proxy.api.AbstractContainer;
-import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty;
-import org.apache.olingo.ext.proxy.context.AttachedEntity;
-import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
-import org.apache.olingo.ext.proxy.context.EntityLinkDesc;
-import org.apache.olingo.ext.proxy.utils.EngineUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class Container implements AbstractContainer {
-
-  private static final long serialVersionUID = -3320312269235907501L;
-
-  /**
-   * Logger.
-   */
-  private static final Logger LOG = LoggerFactory.getLogger(Container.class);
-
-  private final CommonEdmEnabledODataClient<?> client;
-
-  private final EntityContainerFactory factory;
-
-  Container(final CommonEdmEnabledODataClient<?> client, final EntityContainerFactory factory) {
-    this.client = client;
-    this.factory = factory;
-  }
-
-  /**
-   * Transactional changes commit.
-   */
-  @Override
-  public void flush() {
-    final CommonODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(client.getServiceRoot());
-
-    final BatchStreamManager streamManager = (BatchStreamManager) ((ODataStreamedRequest) request).execute();
-
-    final ODataChangeset changeset = streamManager.addChangeset();
-
-    final TransactionItems items = new TransactionItems();
-    final List<EntityLinkDesc> delayedUpdates = new ArrayList<EntityLinkDesc>();
-
-    int pos = 0;
-
-    for (AttachedEntity attachedEntity : EntityContainerFactory.getContext().entityContext()) {
-      final AttachedEntityStatus status = attachedEntity.getStatus();
-      if (((status != AttachedEntityStatus.ATTACHED
-              && status != AttachedEntityStatus.LINKED) || attachedEntity.getEntity().isChanged())
-              && !items.contains(attachedEntity.getEntity())) {
-        pos++;
-        pos = processEntityContext(attachedEntity.getEntity(), pos, items, delayedUpdates, changeset);
-      }
-    }
-
-    processDelayedUpdates(delayedUpdates, pos, items, changeset);
-
-    final ODataBatchResponse response = streamManager.getResponse();
-
-    if (response.getStatusCode() != 202) {
-      throw new IllegalStateException("Operation failed");
-    }
-
-    final Iterator<ODataBatchResponseItem> iter = response.getBody();
-
-    if (!items.isEmpty()) {
-      if (!iter.hasNext()) {
-        throw new IllegalStateException("Unexpected operation result");
-      }
-
-      final ODataBatchResponseItem item = iter.next();
-      if (!(item instanceof ODataChangesetResponseItem)) {
-        throw new IllegalStateException("Unexpected batch response item " + item.getClass().getSimpleName());
-      }
-
-      final ODataChangesetResponseItem chgres = (ODataChangesetResponseItem) item;
-
-      for (Integer changesetItemId : items.sortedValues()) {
-        LOG.debug("Expected changeset item {}", changesetItemId);
-        final ODataResponse res = chgres.next();
-        if (res.getStatusCode() >= 400) {
-          throw new IllegalStateException("Transaction failed: " + res.getStatusMessage());
-        }
-
-        final EntityTypeInvocationHandler<?> handler = items.get(changesetItemId);
-
-        if (handler != null) {
-          if (res instanceof ODataEntityCreateResponse) {
-            LOG.debug("Upgrade created object '{}'", handler);
-            handler.setEntity(((ODataEntityCreateResponse) res).getBody());
-          } else if (res instanceof ODataEntityUpdateResponse) {
-            LOG.debug("Upgrade updated object '{}'", handler);
-            handler.setEntity(((ODataEntityUpdateResponse) res).getBody());
-          }
-        }
-      }
-    }
-
-    EntityContainerFactory.getContext().detachAll();
-  }
-
-  private void batch(
-          final EntityTypeInvocationHandler<?> handler, 
-          final CommonODataEntity entity, 
-          final ODataChangeset changeset) {
-
-    switch (EntityContainerFactory.getContext().entityContext().getStatus(handler)) {
-      case NEW:
-        batchCreate(handler, entity, changeset);
-        break;
-
-      case CHANGED:
-        batchUpdate(handler, entity, changeset);
-        break;
-
-      case DELETED:
-        batchDelete(handler, entity, changeset);
-        break;
-
-      default:
-        if (handler.isChanged()) {
-          batchUpdate(handler, entity, changeset);
-        }
-    }
-  }
-
-  private void batchCreate(
-          final EntityTypeInvocationHandler<?> handler,
-          final CommonODataEntity entity,
-          final ODataChangeset changeset) {
-
-    LOG.debug("Create '{}'", handler);
-
-    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(factory.getServiceRoot()).
-            appendEntitySetSegment(handler.getEntitySetName());
-    changeset.addRequest(client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), entity));
-  }
-
-  private void batchUpdateMediaEntity(
-          final EntityTypeInvocationHandler<?> handler,
-          final URI uri,
-          final InputStream input,
-          final ODataChangeset changeset) {
-
-    LOG.debug("Update media entity '{}'", uri);
-
-    final ODataMediaEntityUpdateRequest<?> req =
-            client.getStreamedRequestFactory().getMediaEntityUpdateRequest(uri, input);
-
-    req.setContentType(StringUtils.isBlank(handler.getEntity().getMediaContentType())
-            ? ODataMediaFormat.WILDCARD.toString()
-            : ODataMediaFormat.fromFormat(handler.getEntity().getMediaContentType()).toString());
-
-    if (StringUtils.isNotBlank(handler.getETag())) {
-      req.setIfMatch(handler.getETag());
-    }
-
-    changeset.addRequest(req);
-  }
-
-  private void batchUpdateMediaResource(
-          final EntityTypeInvocationHandler<?> handler,
-          final URI uri,
-          final InputStream input,
-          final ODataChangeset changeset) {
-
-    LOG.debug("Update media entity '{}'", uri);
-
-    final ODataStreamUpdateRequest req = client.getStreamedRequestFactory().getStreamUpdateRequest(uri, input);
-
-    if (StringUtils.isNotBlank(handler.getETag())) {
-      req.setIfMatch(handler.getETag());
-    }
-
-    changeset.addRequest(req);
-  }
-
-  private void batchUpdate(
-          final EntityTypeInvocationHandler<?> handler,
-          final CommonODataEntity changes,
-          final ODataChangeset changeset) {
-
-    LOG.debug("Update '{}'", changes.getEditLink());
-
-    final ODataEntityUpdateRequest<CommonODataEntity> req =
-            client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
-            ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) client).getCUDRequestFactory().
-            getEntityUpdateRequest(org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
-            : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) client).getCUDRequestFactory().
-            getEntityUpdateRequest(org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
-
-    req.setPrefer(new ODataPreferences(client.getServiceVersion()).returnContent());
-
-    if (StringUtils.isNotBlank(handler.getETag())) {
-      req.setIfMatch(handler.getETag());
-    }
-
-    changeset.addRequest(req);
-  }
-
-  private void batchUpdate(
-          final EntityTypeInvocationHandler<?> handler,
-          final URI uri,
-          final CommonODataEntity changes,
-          final ODataChangeset changeset) {
-
-    LOG.debug("Update '{}'", uri);
-
-    final ODataEntityUpdateRequest<CommonODataEntity> req =
-            client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
-            ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) client).getCUDRequestFactory().
-            getEntityUpdateRequest(
-            uri, org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
-            : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) client).getCUDRequestFactory().
-            getEntityUpdateRequest(
-            uri, org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
-
-    req.setPrefer(new ODataPreferences(client.getServiceVersion()).returnContent());
-
-    if (StringUtils.isNotBlank(handler.getETag())) {
-      req.setIfMatch(handler.getETag());
-    }
-
-    changeset.addRequest(req);
-  }
-
-  private void batchDelete(
-          final EntityTypeInvocationHandler<?> handler,
-          final CommonODataEntity entity,
-          final ODataChangeset changeset) {
-
-    LOG.debug("Delete '{}'", entity.getEditLink());
-
-    final ODataDeleteRequest req = client.getCUDRequestFactory().getDeleteRequest(URIUtils.getURI(
-            factory.getServiceRoot(), entity.getEditLink().toASCIIString()));
-
-    if (StringUtils.isNotBlank(handler.getETag())) {
-      req.setIfMatch(handler.getETag());
-    }
-
-    changeset.addRequest(req);
-  }
-
-  private int processEntityContext(
-          final EntityTypeInvocationHandler<?> handler,
-          int pos,
-          final TransactionItems items,
-          final List<EntityLinkDesc> delayedUpdates,
-          final ODataChangeset changeset) {
-
-    LOG.debug("Process '{}'", handler);
-
-    items.put(handler, null);
-
-    final CommonODataEntity entity = handler.getEntity();
-    entity.getNavigationLinks().clear();
-
-    final AttachedEntityStatus currentStatus = EntityContainerFactory.getContext().entityContext().
-            getStatus(handler);
-
-    if (AttachedEntityStatus.DELETED != currentStatus) {
-      entity.getProperties().clear();
-      EngineUtils.addProperties(client, handler.getPropertyChanges(), entity);
-    }
-
-    for (Map.Entry<NavigationProperty, Object> property : handler.getLinkChanges().entrySet()) {
-      final ODataLinkType type = Collection.class.isAssignableFrom(property.getValue().getClass())
-              ? ODataLinkType.ENTITY_SET_NAVIGATION
-              : ODataLinkType.ENTITY_NAVIGATION;
-
-      final Set<EntityTypeInvocationHandler<?>> toBeLinked = new HashSet<EntityTypeInvocationHandler<?>>();
-      final String serviceRoot = factory.getServiceRoot();
-
-      for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
-              ? (Collection) property.getValue() : Collections.singleton(property.getValue())) {
-
-        final EntityTypeInvocationHandler<?> target =
-                (EntityTypeInvocationHandler) Proxy.getInvocationHandler(proxy);
-
-        final AttachedEntityStatus status =
-                EntityContainerFactory.getContext().entityContext().getStatus(target);
-
-        final URI editLink = target.getEntity().getEditLink();
-
-        if ((status == AttachedEntityStatus.ATTACHED || status == AttachedEntityStatus.LINKED)
-                && !target.isChanged()) {
-          entity.addLink(buildNavigationLink(
-                  property.getKey().name(),
-                  URIUtils.getURI(serviceRoot, editLink.toASCIIString()), type));
-        } else {
-          if (!items.contains(target)) {
-            pos = processEntityContext(target, pos, items, delayedUpdates, changeset);
-            pos++;
-          }
-
-          final Integer targetPos = items.get(target);
-          if (targetPos == null) {
-            // schedule update for the current object
-            LOG.debug("Schedule '{}' from '{}' to '{}'", type.name(), handler, target);
-            toBeLinked.add(target);
-          } else if (status == AttachedEntityStatus.CHANGED) {
-            entity.addLink(buildNavigationLink(
-                    property.getKey().name(),
-                    URIUtils.getURI(serviceRoot, editLink.toASCIIString()), type));
-          } else {
-            // create the link for the current object
-            LOG.debug("'{}' from '{}' to (${}) '{}'", type.name(), handler, targetPos, target);
-
-            entity.addLink(
-                    buildNavigationLink(property.getKey().name(), URI.create("$" + targetPos), type));
-          }
-        }
-      }
-
-      if (!toBeLinked.isEmpty()) {
-        delayedUpdates.add(new EntityLinkDesc(property.getKey().name(), handler, toBeLinked, type));
-      }
-    }
-
-    // insert into the batch
-    LOG.debug("{}: Insert '{}' into the batch", pos, handler);
-    batch(handler, entity, changeset);
-
-    items.put(handler, pos);
-
-    int startingPos = pos;
-
-    if (handler.getEntity().isMediaEntity()) {
-
-      // update media properties
-      if (!handler.getPropertyChanges().isEmpty()) {
-        final URI targetURI = currentStatus == AttachedEntityStatus.NEW
-                ? URI.create("$" + startingPos)
-                : URIUtils.getURI(factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString());
-        batchUpdate(handler, targetURI, entity, changeset);
-        pos++;
-        items.put(handler, pos);
-      }
-
-      // update media content
-      if (handler.getStreamChanges() != null) {
-        final URI targetURI = currentStatus == AttachedEntityStatus.NEW
-                ? URI.create("$" + startingPos + "/$value")
-                : URIUtils.getURI(
-                factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString() + "/$value");
-
-        batchUpdateMediaEntity(handler, targetURI, handler.getStreamChanges(), changeset);
-
-        // update media info (use null key)
-        pos++;
-        items.put(null, pos);
-      }
-    }
-
-    for (Map.Entry<String, InputStream> streamedChanges : handler.getStreamedPropertyChanges().entrySet()) {
-      final URI targetURI = currentStatus == AttachedEntityStatus.NEW
-              ? URI.create("$" + startingPos) : URIUtils.getURI(
-              factory.getServiceRoot(),
-              EngineUtils.getEditMediaLink(streamedChanges.getKey(), entity).toASCIIString());
-
-      batchUpdateMediaResource(handler, targetURI, streamedChanges.getValue(), changeset);
-
-      // update media info (use null key)
-      pos++;
-      items.put(handler, pos);
-    }
-
-    return pos;
-  }
-
-  private ODataLink buildNavigationLink(final String name, final URI uri, final ODataLinkType type) {
-    switch (type) {
-      case ENTITY_NAVIGATION:
-        return client.getObjectFactory().newEntityNavigationLink(name, uri);
-
-      case ENTITY_SET_NAVIGATION:
-        return client.getObjectFactory().newEntitySetNavigationLink(name, uri);
-
-      default:
-        throw new IllegalArgumentException("Invalid link type " + type.name());
-    }
-  }
-
-  private void processDelayedUpdates(
-          final List<EntityLinkDesc> delayedUpdates,
-          int pos,
-          final TransactionItems items,
-          final ODataChangeset changeset) {
-
-    for (EntityLinkDesc delayedUpdate : delayedUpdates) {
-      pos++;
-      items.put(delayedUpdate.getSource(), pos);
-
-      final CommonODataEntity changes =
-              client.getObjectFactory().newEntity(delayedUpdate.getSource().getEntity().getTypeName());
-
-      AttachedEntityStatus status =
-              EntityContainerFactory.getContext().entityContext().getStatus(delayedUpdate.getSource());
-
-      final URI sourceURI;
-      if (status == AttachedEntityStatus.CHANGED) {
-        sourceURI = URIUtils.getURI(
-                factory.getServiceRoot(),
-                delayedUpdate.getSource().getEntity().getEditLink().toASCIIString());
-      } else {
-        int sourcePos = items.get(delayedUpdate.getSource());
-        sourceURI = URI.create("$" + sourcePos);
-      }
-
-      for (EntityTypeInvocationHandler<?> target : delayedUpdate.getTargets()) {
-        status = EntityContainerFactory.getContext().entityContext().getStatus(target);
-
-        final URI targetURI;
-        if (status == AttachedEntityStatus.CHANGED) {
-          targetURI = URIUtils.getURI(
-                  factory.getServiceRoot(), target.getEntity().getEditLink().toASCIIString());
-        } else {
-          int targetPos = items.get(target);
-          targetURI = URI.create("$" + targetPos);
-        }
-
-        changes.addLink(delayedUpdate.getType() == ODataLinkType.ENTITY_NAVIGATION
-                ? client.getObjectFactory().newEntityNavigationLink(delayedUpdate.getSourceName(), targetURI)
-                : client.getObjectFactory().newEntitySetNavigationLink(delayedUpdate.getSourceName(), targetURI));
-
-        LOG.debug("'{}' from {} to {}", new Object[] {
-          delayedUpdate.getType().name(), sourceURI, targetURI});
-      }
-
-      batchUpdate(delayedUpdate.getSource(), sourceURI, changes, changeset);
-    }
-  }
-
-  private class TransactionItems {
-
-    private final List<EntityTypeInvocationHandler<?>> keys = new ArrayList<EntityTypeInvocationHandler<?>>();
-
-    private final List<Integer> values = new ArrayList<Integer>();
-
-    public EntityTypeInvocationHandler<?> get(final Integer value) {
-      if (value != null && values.contains(value)) {
-        return keys.get(values.indexOf(value));
-      } else {
-        return null;
-      }
-    }
-
-    public Integer get(final EntityTypeInvocationHandler<?> key) {
-      if (key != null && keys.contains(key)) {
-        return values.get(keys.indexOf(key));
-      } else {
-        return null;
-      }
-    }
-
-    public void remove(final EntityTypeInvocationHandler<?> key) {
-      if (keys.contains(key)) {
-        values.remove(keys.indexOf(key));
-        keys.remove(key);
-      }
-    }
-
-    public void put(final EntityTypeInvocationHandler<?> key, final Integer value) {
-      // replace just in case of null current value; otherwise add the new entry
-      if (key != null && keys.contains(key) && values.get(keys.indexOf(key)) == null) {
-        remove(key);
-      }
-      keys.add(key);
-      values.add(value);
-    }
-
-    public List<Integer> sortedValues() {
-      final List<Integer> sortedValues = new ArrayList<Integer>(values);
-      Collections.<Integer>sort(sortedValues);
-      return sortedValues;
-    }
-
-    public boolean contains(final EntityTypeInvocationHandler<?> key) {
-      return keys.contains(key);
-    }
-
-    public int size() {
-      return keys.size();
-    }
-
-    public boolean isEmpty() {
-      return keys.isEmpty();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
new file mode 100644
index 0000000..c51e889
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
@@ -0,0 +1,548 @@
+/*
+ * 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.ext.proxy.commons;
+
+import java.io.InputStream;
+import java.lang.reflect.Proxy;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
+import org.apache.olingo.client.api.communication.header.ODataPreferences;
+import org.apache.olingo.client.api.communication.request.ODataStreamedRequest;
+import org.apache.olingo.client.api.communication.request.batch.BatchStreamManager;
+import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest;
+import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem;
+import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
+import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
+import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
+import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
+import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest;
+import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
+import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
+import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
+import org.apache.olingo.client.api.communication.response.ODataResponse;
+import org.apache.olingo.client.api.uri.CommonURIBuilder;
+import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.ODataLink;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.ODataMediaFormat;
+import org.apache.olingo.ext.proxy.EntityContainerFactory;
+import org.apache.olingo.ext.proxy.api.Container;
+import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty;
+import org.apache.olingo.ext.proxy.context.AttachedEntity;
+import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
+import org.apache.olingo.ext.proxy.context.EntityLinkDesc;
+import org.apache.olingo.ext.proxy.utils.EngineUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class ContainerImpl implements Container {
+
+  private static final long serialVersionUID = -3320312269235907501L;
+
+  /**
+   * Logger.
+   */
+  private static final Logger LOG = LoggerFactory.getLogger(ContainerImpl.class);
+
+  private final CommonEdmEnabledODataClient<?> client;
+
+  private final EntityContainerFactory factory;
+
+  ContainerImpl(final CommonEdmEnabledODataClient<?> client, final EntityContainerFactory factory) {
+    this.client = client;
+    this.factory = factory;
+  }
+
+  /**
+   * Transactional changes commit.
+   */
+  @Override
+  public void flush() {
+    final CommonODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(client.getServiceRoot());
+
+    final BatchStreamManager streamManager = (BatchStreamManager) ((ODataStreamedRequest) request).execute();
+
+    final ODataChangeset changeset = streamManager.addChangeset();
+
+    final TransactionItems items = new TransactionItems();
+    final List<EntityLinkDesc> delayedUpdates = new ArrayList<EntityLinkDesc>();
+
+    int pos = 0;
+
+    for (AttachedEntity attachedEntity : EntityContainerFactory.getContext().entityContext()) {
+      final AttachedEntityStatus status = attachedEntity.getStatus();
+      if (((status != AttachedEntityStatus.ATTACHED
+              && status != AttachedEntityStatus.LINKED) || attachedEntity.getEntity().isChanged())
+              && !items.contains(attachedEntity.getEntity())) {
+        pos++;
+        pos = processEntityContext(attachedEntity.getEntity(), pos, items, delayedUpdates, changeset);
+      }
+    }
+
+    processDelayedUpdates(delayedUpdates, pos, items, changeset);
+
+    final ODataBatchResponse response = streamManager.getResponse();
+
+    if (response.getStatusCode() != 202) {
+      throw new IllegalStateException("Operation failed");
+    }
+
+    if (!items.isEmpty()) {
+      final Iterator<ODataBatchResponseItem> iter = response.getBody();
+      if (!iter.hasNext()) {
+        throw new IllegalStateException("Unexpected operation result");
+      }
+
+      final ODataBatchResponseItem item = iter.next();
+      if (!(item instanceof ODataChangesetResponseItem)) {
+        throw new IllegalStateException("Unexpected batch response item " + item.getClass().getSimpleName());
+      }
+
+      final ODataChangesetResponseItem chgres = (ODataChangesetResponseItem) item;
+
+      for (Integer changesetItemId : items.sortedValues()) {
+        LOG.debug("Expected changeset item {}", changesetItemId);
+        final ODataResponse res = chgres.next();
+        if (res.getStatusCode() >= 400) {
+          throw new IllegalStateException("Transaction failed: " + res.getStatusMessage());
+        }
+
+        final EntityTypeInvocationHandler<?> handler = items.get(changesetItemId);
+
+        if (handler != null) {
+          if (res instanceof ODataEntityCreateResponse) {
+            LOG.debug("Upgrade created object '{}'", handler);
+            handler.setEntity(((ODataEntityCreateResponse) res).getBody());
+          } else if (res instanceof ODataEntityUpdateResponse) {
+            LOG.debug("Upgrade updated object '{}'", handler);
+            handler.setEntity(((ODataEntityUpdateResponse) res).getBody());
+          }
+        }
+      }
+    }
+
+    EntityContainerFactory.getContext().detachAll();
+  }
+
+  private void batch(
+          final EntityTypeInvocationHandler<?> handler,
+          final CommonODataEntity entity,
+          final ODataChangeset changeset) {
+
+    switch (EntityContainerFactory.getContext().entityContext().getStatus(handler)) {
+      case NEW:
+        batchCreate(handler, entity, changeset);
+        break;
+
+      case CHANGED:
+        batchUpdate(handler, entity, changeset);
+        break;
+
+      case DELETED:
+        batchDelete(handler, entity, changeset);
+        break;
+
+      default:
+        if (handler.isChanged()) {
+          batchUpdate(handler, entity, changeset);
+        }
+    }
+  }
+
+  private void batchCreate(
+          final EntityTypeInvocationHandler<?> handler,
+          final CommonODataEntity entity,
+          final ODataChangeset changeset) {
+
+    LOG.debug("Create '{}'", handler);
+
+    final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(factory.getServiceRoot()).
+            appendEntitySetSegment(handler.getEntitySetName());
+    changeset.addRequest(client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), entity));
+  }
+
+  private void batchUpdateMediaEntity(
+          final EntityTypeInvocationHandler<?> handler,
+          final URI uri,
+          final InputStream input,
+          final ODataChangeset changeset) {
+
+    LOG.debug("Update media entity '{}'", uri);
+
+    final ODataMediaEntityUpdateRequest<?> req =
+            client.getStreamedRequestFactory().getMediaEntityUpdateRequest(uri, input);
+
+    req.setContentType(StringUtils.isBlank(handler.getEntity().getMediaContentType())
+            ? ODataMediaFormat.WILDCARD.toString()
+            : ODataMediaFormat.fromFormat(handler.getEntity().getMediaContentType()).toString());
+
+    if (StringUtils.isNotBlank(handler.getETag())) {
+      req.setIfMatch(handler.getETag());
+    }
+
+    changeset.addRequest(req);
+  }
+
+  private void batchUpdateMediaResource(
+          final EntityTypeInvocationHandler<?> handler,
+          final URI uri,
+          final InputStream input,
+          final ODataChangeset changeset) {
+
+    LOG.debug("Update media entity '{}'", uri);
+
+    final ODataStreamUpdateRequest req = client.getStreamedRequestFactory().getStreamUpdateRequest(uri, input);
+
+    if (StringUtils.isNotBlank(handler.getETag())) {
+      req.setIfMatch(handler.getETag());
+    }
+
+    changeset.addRequest(req);
+  }
+
+  private void batchUpdate(
+          final EntityTypeInvocationHandler<?> handler,
+          final CommonODataEntity changes,
+          final ODataChangeset changeset) {
+
+    LOG.debug("Update '{}'", changes.getEditLink());
+
+    final ODataEntityUpdateRequest<CommonODataEntity> req =
+            client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
+            ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) client).getCUDRequestFactory().
+            getEntityUpdateRequest(org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
+            : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) client).getCUDRequestFactory().
+            getEntityUpdateRequest(org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
+
+    req.setPrefer(new ODataPreferences(client.getServiceVersion()).returnContent());
+
+    if (StringUtils.isNotBlank(handler.getETag())) {
+      req.setIfMatch(handler.getETag());
+    }
+
+    changeset.addRequest(req);
+  }
+
+  private void batchUpdate(
+          final EntityTypeInvocationHandler<?> handler,
+          final URI uri,
+          final CommonODataEntity changes,
+          final ODataChangeset changeset) {
+
+    LOG.debug("Update '{}'", uri);
+
+    final ODataEntityUpdateRequest<CommonODataEntity> req =
+            client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
+            ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) client).getCUDRequestFactory().
+            getEntityUpdateRequest(
+                    uri, org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
+            : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) client).getCUDRequestFactory().
+            getEntityUpdateRequest(
+                    uri, org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
+
+    req.setPrefer(new ODataPreferences(client.getServiceVersion()).returnContent());
+
+    if (StringUtils.isNotBlank(handler.getETag())) {
+      req.setIfMatch(handler.getETag());
+    }
+
+    changeset.addRequest(req);
+  }
+
+  private void batchDelete(
+          final EntityTypeInvocationHandler<?> handler,
+          final CommonODataEntity entity,
+          final ODataChangeset changeset) {
+
+    LOG.debug("Delete '{}'", entity.getEditLink());
+
+    final ODataDeleteRequest req = client.getCUDRequestFactory().getDeleteRequest(URIUtils.getURI(
+            factory.getServiceRoot(), entity.getEditLink().toASCIIString()));
+
+    if (StringUtils.isNotBlank(handler.getETag())) {
+      req.setIfMatch(handler.getETag());
+    }
+
+    changeset.addRequest(req);
+  }
+
+  private int processEntityContext(
+          final EntityTypeInvocationHandler<?> handler,
+          int pos,
+          final TransactionItems items,
+          final List<EntityLinkDesc> delayedUpdates,
+          final ODataChangeset changeset) {
+
+    LOG.debug("Process '{}'", handler);
+
+    items.put(handler, null);
+
+    final CommonODataEntity entity = handler.getEntity();
+    entity.getNavigationLinks().clear();
+
+    final AttachedEntityStatus currentStatus = EntityContainerFactory.getContext().entityContext().
+            getStatus(handler);
+
+    if (AttachedEntityStatus.DELETED != currentStatus) {
+      entity.getProperties().clear();
+      EngineUtils.addProperties(client, handler.getPropertyChanges(), entity);
+    }
+
+    for (Map.Entry<NavigationProperty, Object> property : handler.getLinkChanges().entrySet()) {
+      final ODataLinkType type = Collection.class.isAssignableFrom(property.getValue().getClass())
+              ? ODataLinkType.ENTITY_SET_NAVIGATION
+              : ODataLinkType.ENTITY_NAVIGATION;
+
+      final Set<EntityTypeInvocationHandler<?>> toBeLinked = new HashSet<EntityTypeInvocationHandler<?>>();
+      final String serviceRoot = factory.getServiceRoot();
+
+      for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
+              ? (Collection) property.getValue() : Collections.singleton(property.getValue())) {
+
+        final EntityTypeInvocationHandler<?> target =
+                (EntityTypeInvocationHandler) Proxy.getInvocationHandler(proxy);
+
+        final AttachedEntityStatus status =
+                EntityContainerFactory.getContext().entityContext().getStatus(target);
+
+        final URI editLink = target.getEntity().getEditLink();
+
+        if ((status == AttachedEntityStatus.ATTACHED || status == AttachedEntityStatus.LINKED)
+                && !target.isChanged()) {
+          entity.addLink(buildNavigationLink(
+                  property.getKey().name(),
+                  URIUtils.getURI(serviceRoot, editLink.toASCIIString()), type));
+        } else {
+          if (!items.contains(target)) {
+            pos = processEntityContext(target, pos, items, delayedUpdates, changeset);
+            pos++;
+          }
+
+          final Integer targetPos = items.get(target);
+          if (targetPos == null) {
+            // schedule update for the current object
+            LOG.debug("Schedule '{}' from '{}' to '{}'", type.name(), handler, target);
+            toBeLinked.add(target);
+          } else if (status == AttachedEntityStatus.CHANGED) {
+            entity.addLink(buildNavigationLink(
+                    property.getKey().name(),
+                    URIUtils.getURI(serviceRoot, editLink.toASCIIString()), type));
+          } else {
+            // create the link for the current object
+            LOG.debug("'{}' from '{}' to (${}) '{}'", type.name(), handler, targetPos, target);
+
+            entity.addLink(
+                    buildNavigationLink(property.getKey().name(), URI.create("$" + targetPos), type));
+          }
+        }
+      }
+
+      if (!toBeLinked.isEmpty()) {
+        delayedUpdates.add(new EntityLinkDesc(property.getKey().name(), handler, toBeLinked, type));
+      }
+    }
+
+    // insert into the batch
+    LOG.debug("{}: Insert '{}' into the batch", pos, handler);
+    batch(handler, entity, changeset);
+
+    items.put(handler, pos);
+
+    int startingPos = pos;
+
+    if (handler.getEntity().isMediaEntity()) {
+
+      // update media properties
+      if (!handler.getPropertyChanges().isEmpty()) {
+        final URI targetURI = currentStatus == AttachedEntityStatus.NEW
+                ? URI.create("$" + startingPos)
+                : URIUtils.getURI(factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString());
+        batchUpdate(handler, targetURI, entity, changeset);
+        pos++;
+        items.put(handler, pos);
+      }
+
+      // update media content
+      if (handler.getStreamChanges() != null) {
+        final URI targetURI = currentStatus == AttachedEntityStatus.NEW
+                ? URI.create("$" + startingPos + "/$value")
+                : URIUtils.getURI(
+                        factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString() + "/$value");
+
+        batchUpdateMediaEntity(handler, targetURI, handler.getStreamChanges(), changeset);
+
+        // update media info (use null key)
+        pos++;
+        items.put(null, pos);
+      }
+    }
+
+    for (Map.Entry<String, InputStream> streamedChanges : handler.getStreamedPropertyChanges().entrySet()) {
+      final URI targetURI = currentStatus == AttachedEntityStatus.NEW
+              ? URI.create("$" + startingPos) : URIUtils.getURI(
+                      factory.getServiceRoot(),
+                      EngineUtils.getEditMediaLink(streamedChanges.getKey(), entity).toASCIIString());
+
+      batchUpdateMediaResource(handler, targetURI, streamedChanges.getValue(), changeset);
+
+      // update media info (use null key)
+      pos++;
+      items.put(handler, pos);
+    }
+
+    return pos;
+  }
+
+  private ODataLink buildNavigationLink(final String name, final URI uri, final ODataLinkType type) {
+    ODataLink result;
+
+    switch (type) {
+      case ENTITY_NAVIGATION:
+        result = client.getObjectFactory().newEntityNavigationLink(name, uri);
+        break;
+
+      case ENTITY_SET_NAVIGATION:
+        result = client.getObjectFactory().newEntitySetNavigationLink(name, uri);
+        break;
+
+      default:
+        throw new IllegalArgumentException("Invalid link type " + type.name());
+    }
+
+    return result;
+  }
+
+  private void processDelayedUpdates(
+          final List<EntityLinkDesc> delayedUpdates,
+          int pos,
+          final TransactionItems items,
+          final ODataChangeset changeset) {
+
+    for (EntityLinkDesc delayedUpdate : delayedUpdates) {
+      pos++;
+      items.put(delayedUpdate.getSource(), pos);
+
+      final CommonODataEntity changes =
+              client.getObjectFactory().newEntity(delayedUpdate.getSource().getEntity().getTypeName());
+
+      AttachedEntityStatus status =
+              EntityContainerFactory.getContext().entityContext().getStatus(delayedUpdate.getSource());
+
+      final URI sourceURI;
+      if (status == AttachedEntityStatus.CHANGED) {
+        sourceURI = URIUtils.getURI(
+                factory.getServiceRoot(),
+                delayedUpdate.getSource().getEntity().getEditLink().toASCIIString());
+      } else {
+        int sourcePos = items.get(delayedUpdate.getSource());
+        sourceURI = URI.create("$" + sourcePos);
+      }
+
+      for (EntityTypeInvocationHandler<?> target : delayedUpdate.getTargets()) {
+        status = EntityContainerFactory.getContext().entityContext().getStatus(target);
+
+        final URI targetURI;
+        if (status == AttachedEntityStatus.CHANGED) {
+          targetURI = URIUtils.getURI(
+                  factory.getServiceRoot(), target.getEntity().getEditLink().toASCIIString());
+        } else {
+          int targetPos = items.get(target);
+          targetURI = URI.create("$" + targetPos);
+        }
+
+        changes.addLink(delayedUpdate.getType() == ODataLinkType.ENTITY_NAVIGATION
+                ? client.getObjectFactory().newEntityNavigationLink(delayedUpdate.getSourceName(), targetURI)
+                : client.getObjectFactory().newEntitySetNavigationLink(delayedUpdate.getSourceName(), targetURI));
+
+        LOG.debug("'{}' from {} to {}", delayedUpdate.getType().name(), sourceURI, targetURI);
+      }
+
+      batchUpdate(delayedUpdate.getSource(), sourceURI, changes, changeset);
+    }
+  }
+
+  private class TransactionItems {
+
+    private final List<EntityTypeInvocationHandler<?>> keys = new ArrayList<EntityTypeInvocationHandler<?>>();
+
+    private final List<Integer> values = new ArrayList<Integer>();
+
+    public EntityTypeInvocationHandler<?> get(final Integer value) {
+      if (value != null && values.contains(value)) {
+        return keys.get(values.indexOf(value));
+      } else {
+        return null;
+      }
+    }
+
+    public Integer get(final EntityTypeInvocationHandler<?> key) {
+      if (key != null && keys.contains(key)) {
+        return values.get(keys.indexOf(key));
+      } else {
+        return null;
+      }
+    }
+
+    public void remove(final EntityTypeInvocationHandler<?> key) {
+      if (keys.contains(key)) {
+        values.remove(keys.indexOf(key));
+        keys.remove(key);
+      }
+    }
+
+    public void put(final EntityTypeInvocationHandler<?> key, final Integer value) {
+      // replace just in case of null current value; otherwise add the new entry
+      if (key != null && keys.contains(key) && values.get(keys.indexOf(key)) == null) {
+        remove(key);
+      }
+      keys.add(key);
+      values.add(value);
+    }
+
+    public List<Integer> sortedValues() {
+      final List<Integer> sortedValues = new ArrayList<Integer>(values);
+      Collections.<Integer>sort(sortedValues);
+      return sortedValues;
+    }
+
+    public boolean contains(final EntityTypeInvocationHandler<?> key) {
+      return keys.contains(key);
+    }
+
+    public int size() {
+      return keys.size();
+    }
+
+    public boolean isEmpty() {
+      return keys.isEmpty();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
index b74e91f..0b5a5be 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
@@ -27,7 +27,7 @@ import org.apache.olingo.ext.proxy.EntityContainerFactory;
 import org.apache.olingo.ext.proxy.api.annotations.EntityContainer;
 import org.apache.olingo.ext.proxy.utils.ClassUtils;
 
-public class EntityContainerInvocationHandler<C extends CommonEdmEnabledODataClient<?>>
+public final class EntityContainerInvocationHandler<C extends CommonEdmEnabledODataClient<?>>
         extends AbstractInvocationHandler<C> {
 
   private static final long serialVersionUID = 7379006755693410764L;
@@ -65,29 +65,28 @@ public class EntityContainerInvocationHandler<C extends CommonEdmEnabledODataCli
     this.namespace = ((EntityContainer) annotation).namespace();
   }
 
-  EntityContainerFactory getFactory() {
+  protected EntityContainerFactory getFactory() {
     return factory;
   }
 
-  boolean isDefaultEntityContainer() {
+  protected boolean isDefaultEntityContainer() {
     return defaultEC;
   }
 
-  String getEntityContainerName() {
+  protected String getEntityContainerName() {
     return name;
   }
 
-  String getSchemaName() {
+  protected String getSchemaName() {
     return namespace;
   }
 
   @Override
-  @SuppressWarnings("unchecked")
   public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
     if (isSelfMethod(method, args)) {
       return invokeSelfMethod(method, args);
     } else if ("flush".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
-      new Container(client, factory).flush();
+      new ContainerImpl(client, factory).flush();
       return ClassUtils.returnVoid();
     } else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
       final Class<?> returnType = method.getReturnType();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ClassUtils.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ClassUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ClassUtils.java
index c4f325f..d3f9119 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ClassUtils.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ClassUtils.java
@@ -73,10 +73,9 @@ public final class ClassUtils {
     return result;
   }
 
-  @SuppressWarnings("unchecked")
   public static <ANN extends Annotation> ANN getAnnotation(final Class<ANN> reference, final AccessibleObject obj) {
     final Annotation ann = obj.getAnnotation(reference);
-    return ann == null ? null : (ANN) ann;
+    return ann == null ? null : reference.cast(ann);
   }
 
   public static Class<?> getCompoundKeyRef(final Class<?> entityTypeRef) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java
index 801250a..0e4ee28 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/EngineUtils.java
@@ -132,6 +132,7 @@ public final class EngineUtils {
           final FullQualifiedName entity,
           final String property,
           final Object obj) {
+    
     final EdmType edmType = client.getCachedEdm().getEntityType(entity).getProperty(property).getType();
     final EdmTypeInfo type = new EdmTypeInfo.Builder().
             setEdm(client.getCachedEdm()).setTypeExpression(edmType.getFullQualifiedName().toString()).build();
@@ -144,6 +145,7 @@ public final class EngineUtils {
           final FullQualifiedName complex,
           final String property,
           final Object obj) {
+    
     final EdmType edmType = client.getCachedEdm().getComplexType(complex).getProperty(property).getType();
     final EdmTypeInfo type = new EdmTypeInfo.Builder().
             setEdm(client.getCachedEdm()).setTypeExpression(edmType.getFullQualifiedName().toString()).build();
@@ -153,7 +155,8 @@ public final class EngineUtils {
 
   private static CommonODataProperty getODataProperty(
           final CommonEdmEnabledODataClient<?> client, final String name, final EdmTypeInfo type, final Object obj) {
-    final CommonODataProperty oprop;
+    
+    CommonODataProperty oprop;
 
     try {
       if (type == null || obj == null) {
@@ -219,7 +222,6 @@ public final class EngineUtils {
     return obj;
   }
 
-  @SuppressWarnings("unchecked")
   private static void setPropertyValue(final Object bean, final Method getter, final Object value)
           throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
 
@@ -259,6 +261,7 @@ public final class EngineUtils {
           final Object bean,
           final Class<? extends Annotation> getterAnn,
           final Iterator<? extends CommonODataProperty> propItor) {
+    
     if (bean != null) {
       populate(metadata, bean, bean.getClass(), getterAnn, propItor);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/pom.xml b/ext/pojogen-maven-plugin/pom.xml
index 2364dac..f0fc429 100644
--- a/ext/pojogen-maven-plugin/pom.xml
+++ b/ext/pojogen-maven-plugin/pom.xml
@@ -85,7 +85,7 @@
         <artifactId>maven-plugin-plugin</artifactId>
         <inherited>true</inherited>
         <configuration>
-          <goalPrefix>odatajclient</goalPrefix>
+          <goalPrefix>pojogen</goalPrefix>
           <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
         </configuration>
         <executions>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/actionOverloadingService/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/actionOverloadingService/pom.xml b/ext/pojogen-maven-plugin/src/it/actionOverloadingService/pom.xml
deleted file mode 100644
index ba36e81..0000000
--- a/ext/pojogen-maven-plugin/src/it/actionOverloadingService/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.olingo.ext</groupId>
-  <artifactId>odatajclient-maven-plugin</artifactId>
-  <version>@project.version@</version>
-
-  <description>A simple IT verifying the basic use case.</description>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>@velocity.version@</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.apache.olingo.ext</groupId>
-      <artifactId>odatajclient-proxy</artifactId>
-      <version>@project.version@</version>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <version>1.8</version>
-        <executions>
-          <execution>
-            <phase>process-sources</phase>
-            <goals>
-              <goal>add-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>${project.build.directory}/generated-sources</source>
-              </sources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      
-      <plugin>
-        <groupId>@project.groupId@</groupId>
-        <artifactId>@project.artifactId@</artifactId>
-        <version>@project.version@</version>
-        <executions>
-          <execution>
-            <configuration>
-              <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
-              <serviceRootURL>@serviceRootURL@/ActionOverloadingService.svc</serviceRootURL>
-              <basePackage>org.apache.olingo.ext.proxy.actionoverloadingservice</basePackage>
-            </configuration>
-            <id>pojosV3</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>pojosV3</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/actionOverloadingService/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/actionOverloadingService/verify.groovy b/ext/pojogen-maven-plugin/src/it/actionOverloadingService/verify.groovy
deleted file mode 100644
index a19cf4d..0000000
--- a/ext/pojogen-maven-plugin/src/it/actionOverloadingService/verify.groovy
+++ /dev/null
@@ -1,20 +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.
- */
-File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
-assert basepkg.isDirectory() && basepkg.listFiles().length>0;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/defaultService/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/defaultService/pom.xml b/ext/pojogen-maven-plugin/src/it/defaultService/pom.xml
deleted file mode 100644
index c82709f..0000000
--- a/ext/pojogen-maven-plugin/src/it/defaultService/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.olingo.ext</groupId>
-  <artifactId>odatajclient-maven-plugin</artifactId>
-  <version>@project.version@</version>
-
-  <description>A simple IT verifying the basic use case.</description>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>@velocity.version@</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.apache.olingo.ext</groupId>
-      <artifactId>odatajclient-proxy</artifactId>
-      <version>@project.version@</version>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <version>1.8</version>
-        <executions>
-          <execution>
-            <phase>process-sources</phase>
-            <goals>
-              <goal>add-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>${project.build.directory}/generated-sources</source>
-              </sources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      
-      <plugin>
-        <groupId>@project.groupId@</groupId>
-        <artifactId>@project.artifactId@</artifactId>
-        <version>@project.version@</version>
-        <executions>
-          <execution>
-            <configuration>
-              <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
-              <serviceRootURL>@serviceRootURL@/DefaultService.svc</serviceRootURL>
-              <basePackage>org.apache.olingo.ext.proxy.defaultservice</basePackage>
-            </configuration>
-            <id>pojosV3</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>pojosV3</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/defaultService/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/defaultService/verify.groovy b/ext/pojogen-maven-plugin/src/it/defaultService/verify.groovy
deleted file mode 100644
index a19cf4d..0000000
--- a/ext/pojogen-maven-plugin/src/it/defaultService/verify.groovy
+++ /dev/null
@@ -1,20 +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.
- */
-File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
-assert basepkg.isDirectory() && basepkg.listFiles().length>0;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/pom.xml b/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/pom.xml
deleted file mode 100644
index 174ee91..0000000
--- a/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.olingo.ext</groupId>
-  <artifactId>odatajclient-maven-plugin</artifactId>
-  <version>@project.version@</version>
-
-  <description>A simple IT verifying the basic use case.</description>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>@velocity.version@</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.apache.olingo.ext</groupId>
-      <artifactId>odatajclient-proxy</artifactId>
-      <version>@project.version@</version>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <version>1.8</version>
-        <executions>
-          <execution>
-            <phase>process-sources</phase>
-            <goals>
-              <goal>add-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>${project.build.directory}/generated-sources</source>
-              </sources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      
-      <plugin>
-        <groupId>@project.groupId@</groupId>
-        <artifactId>@project.artifactId@</artifactId>
-        <version>@project.version@</version>
-        <executions>
-          <execution>
-            <configuration>
-              <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
-              <serviceRootURL>@serviceRootURL@/KeyAsSegmentService.svc</serviceRootURL>
-              <basePackage>org.apache.olingo.ext.proxy.keyassegmentservice</basePackage>
-            </configuration>
-            <id>pojosV3</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>pojosV3</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/verify.groovy b/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/verify.groovy
deleted file mode 100644
index a19cf4d..0000000
--- a/ext/pojogen-maven-plugin/src/it/keyAsSegmentService/verify.groovy
+++ /dev/null
@@ -1,20 +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.
- */
-File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
-assert basepkg.isDirectory() && basepkg.listFiles().length>0;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/northwind/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/northwind/pom.xml b/ext/pojogen-maven-plugin/src/it/northwind/pom.xml
deleted file mode 100644
index 862493a..0000000
--- a/ext/pojogen-maven-plugin/src/it/northwind/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.olingo.ext</groupId>
-  <artifactId>odatajclient-maven-plugin</artifactId>
-  <version>@project.version@</version>
-
-  <description>A simple IT verifying the basic use case.</description>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>@velocity.version@</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.apache.olingo.ext</groupId>
-      <artifactId>odatajclient-proxy</artifactId>
-      <version>@project.version@</version>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <version>1.8</version>
-        <executions>
-          <execution>
-            <phase>process-sources</phase>
-            <goals>
-              <goal>add-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>${project.build.directory}/generated-sources</source>
-              </sources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      
-      <plugin>
-        <groupId>@project.groupId@</groupId>
-        <artifactId>@project.artifactId@</artifactId>
-        <version>@project.version@</version>
-        <executions>
-          <execution>
-            <configuration>
-              <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
-              <serviceRootURL>http://services.odata.org/v3/(S(g00nkir0ssikgdmz3maw5l1x))/Northwind/Northwind.svc</serviceRootURL>
-              <basePackage>org.apache.olingo.ext.proxy.northwind</basePackage>
-            </configuration>
-	    <id>pojosV3</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>pojosV3</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/northwind/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/northwind/verify.groovy b/ext/pojogen-maven-plugin/src/it/northwind/verify.groovy
deleted file mode 100644
index a19cf4d..0000000
--- a/ext/pojogen-maven-plugin/src/it/northwind/verify.groovy
+++ /dev/null
@@ -1,20 +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.
- */
-File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
-assert basepkg.isDirectory() && basepkg.listFiles().length>0;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/pom.xml
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/pom.xml b/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/pom.xml
deleted file mode 100644
index 0f133b4..0000000
--- a/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.olingo.ext</groupId>
-  <artifactId>odatajclient-maven-plugin</artifactId>
-  <version>@project.version@</version>
-
-  <description>A simple IT verifying the basic use case.</description>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-  
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>@velocity.version@</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.apache.olingo.ext</groupId>
-      <artifactId>odatajclient-proxy</artifactId>
-      <version>@project.version@</version>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <version>1.8</version>
-        <executions>
-          <execution>
-            <phase>process-sources</phase>
-            <goals>
-              <goal>add-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>${project.build.directory}/generated-sources</source>
-              </sources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      
-      <plugin>
-        <groupId>@project.groupId@</groupId>
-        <artifactId>@project.artifactId@</artifactId>
-        <version>@project.version@</version>
-        <executions>
-          <execution>
-            <configuration>
-              <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
-              <serviceRootURL>@serviceRootURL@/ODataWriterDefaultService.svc</serviceRootURL>
-              <basePackage>org.apache.olingo.ext.proxy.odatawriterdefaultservice</basePackage>
-            </configuration>
-            <id>pojosV3</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>pojosV3</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/40895b8b/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/verify.groovy
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/verify.groovy b/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/verify.groovy
deleted file mode 100644
index a19cf4d..0000000
--- a/ext/pojogen-maven-plugin/src/it/odataWriterDefaultService/verify.groovy
+++ /dev/null
@@ -1,20 +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.
- */
-File basepkg = new File( basedir, "target/generated-sources/ojc-plugin/com/msopentech/odatajclient/proxy" );
-assert basepkg.isDirectory() && basepkg.listFiles().length>0;