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/07/26 12:21:59 UTC

[12/32] [OLINGO-366] provided operation invokers

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java
index 02864f6..6f54781 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java
@@ -29,21 +29,20 @@ import org.apache.olingo.ext.proxy.AbstractService;
 import org.apache.olingo.ext.proxy.api.EntityCollection;
 import org.apache.olingo.ext.proxy.api.EntityType;
 
-public class EntityCollectionInvocationHandler<T extends EntityType>
-        extends AbstractEntityCollectionInvocationHandler<T, EntityCollection<T>>
-        implements EntityCollection<T> {
+public class EntityCollectionInvocationHandler<T extends EntityType<?>>
+        extends AbstractEntityCollectionInvocationHandler<T, EntityCollection<T, ?, ?>> {
 
   private static final long serialVersionUID = 98078202642671726L;
 
   public EntityCollectionInvocationHandler(
-          final AbstractService<?> service, final Class<? extends EntityCollection<T>> collItemRef) {
+          final AbstractService<?> service, final Class<? extends EntityCollection<T, ?, ?>> collItemRef) {
     this(service, new ArrayList<T>(), collItemRef, null, null);
   }
 
-  public <EC extends EntityCollection<T>> EntityCollectionInvocationHandler(
+  public <EC extends EntityCollection<T, ?, ?>> EntityCollectionInvocationHandler(
           final AbstractService<?> service,
           final Collection<T> items,
-          final Class<? extends EntityCollection<T>> collItemRef,
+          final Class<? extends EntityCollection<T, ?, ?>> collItemRef,
           final URI targetEntitySetURI,
           final CommonURIBuilder<?> uri) {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/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 f428a60..4339cba 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
@@ -155,7 +155,8 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
   }
 
   @SuppressWarnings("unchecked")
-  public <T extends EntityType, NEC extends EntityCollection<T>> NEC newEntityCollection(final Class<NEC> ref) {
+  public <T extends EntityType<?>, NEC extends EntityCollection<T, ?, ?>> NEC newEntityCollection(
+          final Class<NEC> ref) {
     return (NEC) Proxy.newProxyInstance(
             Thread.currentThread().getContextClassLoader(),
             new Class<?>[] {ref},
@@ -163,7 +164,7 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
   }
 
   @SuppressWarnings("unchecked")
-  public <NE extends ComplexType> NE newComplexInstance(final Class<NE> ref) {
+  public <NE extends ComplexType<?>> NE newComplexInstance(final Class<NE> ref) {
     return (NE) Proxy.newProxyInstance(
             Thread.currentThread().getContextClassLoader(),
             new Class<?>[] {ref},
@@ -171,7 +172,8 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
   }
 
   @SuppressWarnings("unchecked")
-  public <T extends ComplexType, NEC extends ComplexCollection<T>> NEC newComplexCollection(final Class<NEC> ref) {
+  public <T extends ComplexType<?>, NEC extends ComplexCollection<T, ?, ?>> NEC newComplexCollection(
+          final Class<NEC> ref) {
     final Class<T> itemRef = (Class<T>) ClassUtils.extractTypeArg(ref, ComplexCollection.class);
 
     return (NEC) Proxy.newProxyInstance(

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
index 0199d1b..72355c3 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
@@ -42,27 +42,28 @@ import org.apache.olingo.ext.proxy.api.AbstractSingleton;
 import org.apache.olingo.ext.proxy.api.EntityCollection;
 import org.apache.olingo.ext.proxy.api.EntityType;
 import org.apache.olingo.ext.proxy.api.Search;
-import org.apache.olingo.ext.proxy.api.SingleQuery;
+import org.apache.olingo.ext.proxy.api.StructuredType;
 import org.apache.olingo.ext.proxy.api.annotations.Namespace;
 import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
 import org.apache.olingo.ext.proxy.context.EntityContext;
 import org.apache.olingo.ext.proxy.context.EntityUUID;
 import org.apache.olingo.ext.proxy.utils.ClassUtils;
 
-class EntitySetInvocationHandler<
-        T extends EntityType, KEY extends Serializable, EC extends EntityCollection<T>>
+public class EntitySetInvocationHandler<
+        T extends EntityType<?>, KEY extends Serializable, EC extends EntityCollection<T, ?, ?>>
         extends AbstractEntityCollectionInvocationHandler<T, EC>
         implements AbstractEntitySet<T, KEY, EC> {
 
   private static final long serialVersionUID = 2629912294765040027L;
 
   @SuppressWarnings({"rawtypes", "unchecked"})
-  static EntitySetInvocationHandler getInstance(final Class<?> ref, final AbstractService<?> service) {
+  public static EntitySetInvocationHandler getInstance(final Class<?> ref, final AbstractService<?> service) {
     return new EntitySetInvocationHandler(ref, service, buildEntitySetURI(ref, service));
   }
 
   @SuppressWarnings({"rawtypes", "unchecked"})
-  static EntitySetInvocationHandler getInstance(final Class<?> ref, final AbstractService<?> service, final URI uri) {
+  public static EntitySetInvocationHandler getInstance(
+          final Class<?> ref, final AbstractService<?> service, final URI uri) {
     return new EntitySetInvocationHandler(ref, service, service.getClient().newURIBuilder(uri.toASCIIString()));
   }
 
@@ -104,7 +105,7 @@ class EntitySetInvocationHandler<
   @Override
   public Boolean exists(final KEY key) throws IllegalArgumentException {
     try {
-      SingleQuery.class.cast(getByKey(key)).load();
+      StructuredType.class.cast(getByKey(key)).load();
       return true;
     } catch (Exception e) {
       LOG.error("Could not check existence of {}({})", this.uri, key, e);
@@ -151,9 +152,8 @@ class EntitySetInvocationHandler<
     return execute(collItemRef);
   }
 
-  public <S extends T, SEC extends EntityCollection<S>> Future<SEC> executeAsync(final Class<SEC> collTypeRef) {
+  public <S extends T, SEC extends EntityCollection<S, ?, ?>> Future<SEC> executeAsync(final Class<SEC> collTypeRef) {
     return service.getClient().getConfiguration().getExecutor().submit(new Callable<SEC>() {
-
       @Override
       public SEC call() throws Exception {
         return execute(collTypeRef);
@@ -162,7 +162,7 @@ class EntitySetInvocationHandler<
   }
 
   @SuppressWarnings("unchecked")
-  public <S extends T, SEC extends EntityCollection<S>> SEC execute(final Class<SEC> collTypeRef) {
+  public <S extends T, SEC extends EntityCollection<S, ?, ?>> SEC execute(final Class<SEC> collTypeRef) {
     final Class<S> ref = (Class<S>) ClassUtils.extractTypeArg(collTypeRef,
             AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class);
     final Class<S> oref = (Class<S>) ClassUtils.extractTypeArg(this.collItemRef,
@@ -202,7 +202,7 @@ class EntitySetInvocationHandler<
 
   @Override
   @SuppressWarnings("unchecked")
-  public <S extends T, SEC extends EntityCollection<S>> Search<S, SEC> createSearch(final Class<SEC> reference) {
+  public <S extends T, SEC extends EntityCollection<S, ?, ?>> Search<S, SEC> createSearch(final Class<SEC> reference) {
 
     if (getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0) {
       throw new UnsupportedInV3Exception();
@@ -215,7 +215,7 @@ class EntitySetInvocationHandler<
   }
 
   @SuppressWarnings("unchecked")
-  public <S extends T, SEC extends EntityCollection<S>> SEC fetchWholeEntitySet(
+  public <S extends T, SEC extends EntityCollection<S, ?, ?>> SEC fetchWholeEntitySet(
           final CommonURIBuilder<?> uriBuilder, final Class<S> typeRef, final Class<SEC> collTypeRef) {
 
     final List<S> res = new ArrayList<S>();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java
index 77d58f7..8ac25ed 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java
@@ -30,7 +30,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
 import org.apache.olingo.ext.proxy.api.EntityCollection;
 import org.apache.olingo.ext.proxy.api.EntityType;
 
-class EntitySetIterator<T extends EntityType, KEY extends Serializable, EC extends EntityCollection<T>>
+class EntitySetIterator<T extends EntityType<?>, KEY extends Serializable, EC extends EntityCollection<T, ?, ?>>
         implements Iterator<T> {
 
   private final EntitySetInvocationHandler<T, KEY, EC> esi;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerHandler.java
new file mode 100644
index 0000000..fecc4cb
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerHandler.java
@@ -0,0 +1,292 @@
+/*
+ * 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.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.uri.CommonURIBuilder;
+import org.apache.olingo.client.api.uri.URIFilter;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataInvokeResult;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.edm.EdmFunction;
+import org.apache.olingo.commons.api.edm.EdmOperation;
+import org.apache.olingo.commons.api.edm.EdmReturnType;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.ext.proxy.AbstractService;
+import org.apache.olingo.ext.proxy.api.ComplexCollection;
+import org.apache.olingo.ext.proxy.api.EntityCollection;
+import org.apache.olingo.ext.proxy.api.OperationType;
+import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
+import org.apache.olingo.ext.proxy.api.Sort;
+import org.apache.olingo.ext.proxy.api.annotations.Operation;
+import org.apache.olingo.ext.proxy.utils.ClassUtils;
+import org.apache.olingo.ext.proxy.utils.CoreUtils;
+import org.apache.olingo.ext.proxy.utils.ProxyUtils;
+
+public class InvokerHandler<T, C> extends AbstractInvocationHandler {
+
+  private final URI baseURI;
+
+  private CommonURIBuilder<?> uri;
+
+  private final Map<String, ODataValue> parameters;
+
+  private final Operation operation;
+
+  private final EdmOperation edmOperation;
+
+  private final Class<T> reference;
+
+  public InvokerHandler(
+          final URI uri,
+          final Map<String, ODataValue> parameters,
+          final Operation operation,
+          final EdmOperation edmOperation,
+          final Class<T> reference,
+          final AbstractService<?> service) {
+
+    super(service);
+
+    this.baseURI = uri;
+    this.uri = this.baseURI == null ? null : service.getClient().newURIBuilder(this.baseURI.toASCIIString());
+    this.parameters = parameters;
+    this.edmOperation = edmOperation;
+    this.operation = operation;
+    this.reference = reference;
+  }
+
+  public C compose() {
+    return null;
+  }
+
+  @SuppressWarnings({"unchecked", "rawtypes"})
+  public T execute() {
+    if (operation == null || uri == null) {
+      throw new IllegalStateException("Invalid operation");
+    }
+
+    try {
+      // 1. IMPORTANT: flush any pending change *before* invoke if this operation is side effecting
+      if (operation.type() == OperationType.ACTION) {
+        service.getPersistenceManager().flush();
+      }
+
+      // 2. invoke
+      final ODataInvokeResult result = service.getClient().getInvokeRequestFactory().getInvokeRequest(
+              edmOperation instanceof EdmFunction ? HttpMethod.GET : HttpMethod.POST,
+              uri.build(),
+              getResultReference(edmOperation.getReturnType()),
+              parameters).
+              execute().getBody();
+
+      // 3. process invoke result
+      if (StringUtils.isBlank(operation.returnType())) {
+        return (T) ClassUtils.returnVoid();
+      }
+
+      final EdmTypeInfo edmType = new EdmTypeInfo.Builder().
+              setEdm(service.getClient().getCachedEdm()).setTypeExpression(operation.returnType()).build();
+
+      if (edmType.isEntityType()) {
+        if (edmType.isCollection()) {
+          final Class<?> collItemType = ClassUtils.extractTypeArg(reference, EntityCollection.class);
+          return (T) ProxyUtils.getEntityCollectionProxy(
+                  service,
+                  collItemType,
+                  reference,
+                  null,
+                  (CommonODataEntitySet) result,
+                  this.baseURI,
+                  false);
+        } else {
+          return (T) ProxyUtils.getEntityProxy(
+                  service,
+                  (CommonODataEntity) result,
+                  null,
+                  reference,
+                  null,
+                  false);
+        }
+      } else {
+        Object res;
+
+        final Class<?> ref = ClassUtils.getTypeClass(reference);
+        final CommonODataProperty property = (CommonODataProperty) result;
+
+        if (property == null || property.hasNullValue()) {
+          res = null;
+        } else if (edmType.isCollection()) {
+          if (edmType.isComplexType()) {
+            final Class<?> itemRef = ClassUtils.extractTypeArg(ref, ComplexCollection.class);
+            final List items = new ArrayList();
+
+            for (ODataValue item : property.getValue().asCollection()) {
+              items.add(ProxyUtils.getComplex(
+                      service,
+                      property.getName(),
+                      item,
+                      itemRef,
+                      null,
+                      null,
+                      true));
+            }
+
+            res = Proxy.newProxyInstance(
+                    Thread.currentThread().getContextClassLoader(),
+                    new Class<?>[] {ref}, new ComplexCollectionInvocationHandler(
+                    service,
+                    items,
+                    itemRef,
+                    null));
+          } else {
+            final List items = new ArrayList();
+
+            for (ODataValue item : property.getValue().asCollection()) {
+              items.add(item.asPrimitive().toValue());
+            }
+
+            res = Proxy.newProxyInstance(
+                    Thread.currentThread().getContextClassLoader(),
+                    new Class<?>[] {PrimitiveCollection.class}, new PrimitiveCollectionInvocationHandler(
+                    service,
+                    items,
+                    null,
+                    null));
+          }
+        } else {
+          if (edmType.isComplexType()) {
+            res = ProxyUtils.getComplex(
+                    service, property.getName(), property.getValue().asComplex(), ref, null, null, false);
+          } else {
+            res = CoreUtils.getObjectFromODataValue(property.getValue(), reference, service);
+          }
+        }
+
+        return (T) res;
+      }
+    } catch (Exception e) {
+      throw new IllegalStateException(e);
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private <RES extends ODataInvokeResult> Class<RES> getResultReference(final EdmReturnType returnType) {
+    Class<RES> result;
+
+    if (returnType == null) {
+      result = (Class<RES>) ODataNoContent.class;
+    } else {
+      if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
+        result = (Class<RES>) CommonODataEntitySet.class;
+      } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
+        result = (Class<RES>) CommonODataEntity.class;
+      } else {
+        result = (Class<RES>) CommonODataProperty.class;
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+    if ("filter".equals(method.getName())
+            || "orderBy".equals(method.getName())
+            || "top".equals(method.getName())
+            || "skip".equals(method.getName())
+            || "expand".equals(method.getName())
+            || "select".equals(method.getName())) {
+      invokeSelfMethod(method, args);
+      return proxy;
+    } else if (isSelfMethod(method, args)) {
+      return invokeSelfMethod(method, args);
+    } else {
+      throw new NoSuchMethodException(method.getName());
+    }
+  }
+
+  public void filter(final String filter) {
+    if (this.uri != null) {
+      this.uri.filter(filter);
+    }
+  }
+
+  public void filter(final URIFilter filter) {
+    if (this.uri != null) {
+      this.uri.filter(filter);
+    }
+  }
+
+  public void orderBy(final Sort... sort) {
+    if (this.uri != null) {
+      final StringBuilder builder = new StringBuilder();
+      for (Sort sortClause : sort) {
+        builder.append(sortClause.getKey()).append(' ').append(sortClause.getValue()).append(',');
+      }
+      builder.deleteCharAt(builder.length() - 1);
+
+      this.uri.orderBy(builder.toString());
+    }
+  }
+
+  public void orderBy(final String orderBy) {
+    if (this.uri != null) {
+      this.uri.orderBy(orderBy);
+    }
+  }
+
+  public void top(final int top) throws IllegalArgumentException {
+    if (this.uri != null) {
+      this.uri.top(top);
+    }
+  }
+
+  public void skip(final int skip) throws IllegalArgumentException {
+    if (this.uri != null) {
+      this.uri.skip(skip);
+    }
+  }
+
+  public void expand(final String... expand) {
+    if (this.uri != null) {
+      this.uri.expand(expand);
+    }
+  }
+
+  public void select(final String... select) {
+    if (this.uri != null) {
+      this.uri.select(select);
+    }
+  }
+
+  public void clearQueryOptions() {
+    this.uri = this.baseURI == null ? null : getClient().newURIBuilder(baseURI.toASCIIString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
index 32226f8..0fb8b96 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
@@ -36,12 +36,16 @@ import org.apache.olingo.ext.proxy.utils.ClassUtils;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.net.URI;
 import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.ext.proxy.utils.CoreUtils;
 
 final class OperationInvocationHandler extends AbstractInvocationHandler implements OperationExecutor {
 
@@ -119,13 +123,13 @@ final class OperationInvocationHandler extends AbstractInvocationHandler impleme
   }
 
   @Override
+  @SuppressWarnings({"unchecked", "rawtypes"})
   public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
     if (isSelfMethod(method, args)) {
       return invokeSelfMethod(method, args);
     } else {
-      final Annotation[] methodAnnots = method.getAnnotations();
-      if (methodAnnots[0] instanceof Operation) {
-        final Operation operation = (Operation) methodAnnots[0];
+      final Operation operation = method.getAnnotation(Operation.class);
+      if (operation != null) {
 
         final Annotation[][] annotations = method.getParameterAnnotations();
         final List<String> parameterNames;
@@ -160,7 +164,33 @@ final class OperationInvocationHandler extends AbstractInvocationHandler impleme
           throw new IllegalStateException("Invalid target invocation");
         }
 
-        return invokeOperation(operation, method, parameters, edmOperation.getKey(), edmOperation.getValue());
+        final Map<String, ODataValue> parameterValues = new LinkedHashMap<String, ODataValue>();
+        for (Map.Entry<Parameter, Object> parameter : parameters.entrySet()) {
+
+          if (!parameter.getKey().nullable() && parameter.getValue() == null) {
+            throw new IllegalArgumentException(
+                    "Parameter " + parameter.getKey().name() + " is not nullable but a null value was provided");
+          }
+
+          final EdmTypeInfo type = new EdmTypeInfo.Builder().
+                  setEdm(service.getClient().getCachedEdm()).setTypeExpression(parameter.getKey().type()).build();
+
+          final ODataValue paramValue = parameter.getValue() == null
+                  ? null
+                  : CoreUtils.getODataValue(service.getClient(), type, parameter.getValue());
+
+          parameterValues.put(parameter.getKey().name(), paramValue);
+        }
+
+        return Proxy.newProxyInstance(
+                Thread.currentThread().getContextClassLoader(),
+                new Class<?>[] {method.getReturnType()}, new InvokerHandler(
+                edmOperation.getKey(),
+                parameterValues,
+                operation,
+                edmOperation.getValue(),
+                operation.referenceType(),
+                service));
       } else {
         throw new NoSuchMethodException(method.getName());
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java
index e994d6f..7956226 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java
@@ -29,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.EntityType;
 import org.apache.olingo.ext.proxy.api.Search;
 import org.apache.olingo.ext.proxy.utils.ClassUtils;
 
-public class SearchImpl<T extends EntityType, EC extends EntityCollection<T>> implements Search<T, EC> {
+public class SearchImpl<T extends EntityType<?>, EC extends EntityCollection<T, ?, ?>> implements Search<T, EC> {
 
   private static final long serialVersionUID = 4383858176507769973L;
 
@@ -50,7 +50,7 @@ public class SearchImpl<T extends EntityType, EC extends EntityCollection<T>> im
           final Class<EC> collTypeRef, final URI baseURI, final EntitySetInvocationHandler<T, ?, EC> handler) {
 
     this.client = client;
-    this.typeRef = (Class<T>) ClassUtils.extractTypeArg(collTypeRef);
+    this.typeRef = (Class<T>) ClassUtils.extractTypeArg(collTypeRef, EntityCollection.class);
     this.collTypeRef = collTypeRef;
     this.baseURI = baseURI;
     this.handler = handler;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
index dbb4222..aaf2d78 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
@@ -535,13 +535,23 @@ public final class CoreUtils {
       }
     }
 
+    return getObjectFromODataValue(value, internalRef, service);
+  }
+
+  public static Object getObjectFromODataValue(
+          final ODataValue value,
+          final Class<?> ref,
+          final AbstractService<?> service)
+          throws InstantiationException, IllegalAccessException {
+
+
     final Object res;
 
     if (value == null) {
       res = null;
     } else if (value.isComplex()) {
       // complex types supports inheritance in V4, best to re-read actual type
-      internalRef = getComplexTypeRef(service, value);
+      Class<?> internalRef = getComplexTypeRef(service, value);
       res = Proxy.newProxyInstance(
               Thread.currentThread().getContextClassLoader(),
               new Class<?>[] {internalRef},
@@ -553,9 +563,9 @@ public final class CoreUtils {
       while (collPropItor.hasNext()) {
         final ODataValue itemValue = collPropItor.next();
         if (itemValue.isPrimitive()) {
-          collection.add(CoreUtils.primitiveValueToObject(itemValue.asPrimitive(), internalRef));
+          collection.add(CoreUtils.primitiveValueToObject(itemValue.asPrimitive(), ref));
         } else if (itemValue.isComplex()) {
-          internalRef = getComplexTypeRef(service, value);
+          Class<?> internalRef = getComplexTypeRef(service, value);
           final Object collItem = Proxy.newProxyInstance(
                   Thread.currentThread().getContextClassLoader(),
                   new Class<?>[] {internalRef},
@@ -567,12 +577,9 @@ public final class CoreUtils {
 
       res = collection;
     } else if (value instanceof ODataEnumValue) {
-      if (internalRef == null) {
-        internalRef = getEnumTypeRef(service, value);
-      }
-      res = enumValueToObject((ODataEnumValue) value, internalRef);
+      res = enumValueToObject((ODataEnumValue) value, ref == null ? getEnumTypeRef(service, value) : ref);
     } else {
-      res = primitiveValueToObject(value.asPrimitive(), internalRef);
+      res = primitiveValueToObject(value.asPrimitive(), ref);
     }
 
     return res;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ProxyUtils.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ProxyUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ProxyUtils.java
new file mode 100644
index 0000000..65b6ff0
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ProxyUtils.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.utils;
+
+import java.lang.reflect.Proxy;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.uri.CommonURIBuilder;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.ext.proxy.AbstractService;
+import org.apache.olingo.ext.proxy.api.ComplexType;
+import org.apache.olingo.ext.proxy.commons.ComplexInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityCollectionInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntitySetInvocationHandler;
+
+public class ProxyUtils {
+
+  @SuppressWarnings({"unchecked", "rawtypes"})
+  public static Object getEntityCollectionProxy(
+          final AbstractService<?> service,
+          final Class<?> typeRef,
+          final Class<?> typeCollectionRef,
+          final URI targetEntitySetURI,
+          final CommonODataEntitySet entitySet,
+          final URI uri,
+          final boolean checkInTheContext) {
+
+    final List<Object> items = new ArrayList<Object>();
+
+    if (entitySet != null) {
+      for (CommonODataEntity entityFromSet : entitySet.getEntities()) {
+        items.add(getEntityProxy(service, entityFromSet, uri, typeRef, null, checkInTheContext));
+      }
+    }
+
+    return Proxy.newProxyInstance(
+            Thread.currentThread().getContextClassLoader(),
+            new Class<?>[] {typeCollectionRef},
+            new EntityCollectionInvocationHandler(service, items, typeCollectionRef, targetEntitySetURI,
+            uri == null ? null : service.getClient().newURIBuilder(uri.toASCIIString())));
+  }
+
+  public static Object getEntitySetProxy(
+          final AbstractService<?> service,
+          final Class<?> typeRef,
+          final URI uri) {
+
+    return Proxy.newProxyInstance(
+            Thread.currentThread().getContextClassLoader(),
+            new Class<?>[] {typeRef},
+            EntitySetInvocationHandler.getInstance(typeRef, service, uri));
+  }
+
+  public static Object getEntityProxy(
+          final AbstractService<?> service,
+          final CommonODataEntity entity,
+          final URI entitySetURI,
+          final Class<?> type,
+          final String eTag,
+          final boolean checkInTheContext) {
+
+    EntityInvocationHandler handler = EntityInvocationHandler.getInstance(entity, entitySetURI, type, service);
+
+    if (StringUtils.isNotBlank(eTag)) {
+      // override ETag into the wrapped object.
+      handler.setETag(eTag);
+    }
+
+    if (checkInTheContext && service.getContext().entityContext().isAttached(handler)) {
+      handler = service.getContext().entityContext().getEntity(handler.getUUID());
+      handler.setEntity(entity);
+    }
+
+    return Proxy.newProxyInstance(
+            Thread.currentThread().getContextClassLoader(),
+            new Class<?>[] {type},
+            handler);
+  }
+
+  public static ComplexType getComplex(
+          final AbstractService<?> service,
+          final String name,
+          final ODataValue value,
+          final Class<?> ref,
+          final EntityInvocationHandler handler,
+          final URI baseURI,
+          final boolean collectionItem) {
+
+    final CommonURIBuilder<?> targetURI;
+    if (collectionItem) {
+      targetURI = null;
+    } else {
+      targetURI = baseURI == null
+              ? null : service.getClient().newURIBuilder(baseURI.toASCIIString()).appendPropertySegment(name);
+    }
+
+    final ComplexInvocationHandler complexHandler;
+    Class<?> actualRef = ref;
+    if (value == null) {
+      complexHandler = ComplexInvocationHandler.getInstance(
+              actualRef,
+              service,
+              targetURI);
+    } else {
+      actualRef = CoreUtils.getComplexTypeRef(service, value); // handle derived types
+      complexHandler = ComplexInvocationHandler.getInstance(
+              value.asComplex(),
+              actualRef,
+              service,
+              targetURI);
+    }
+
+    complexHandler.setEntityHandler(handler);
+
+    final ComplexType res = ComplexType.class.cast(Proxy.newProxyInstance(
+            Thread.currentThread().getContextClassLoader(),
+            new Class<?>[] {actualRef}, complexHandler));
+
+    return res;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java
index 8fcc246..57550e3 100644
--- a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java
+++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java
@@ -47,6 +47,7 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 
 public abstract class AbstractUtility {
 
@@ -215,6 +216,10 @@ public abstract class AbstractUtility {
     return null;
   }
 
+  public boolean isStreamType(final EdmType type) {
+    return type != null && type.getFullQualifiedName().equals(EdmPrimitiveTypeKind.Stream.getFullQualifiedName());
+  }
+
   public List<EdmFunction> getFunctionsBoundTo(final String typeExpression, final boolean collection) {
     final List<EdmFunction> result = new ArrayList<EdmFunction>();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/resources/complexCollection.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/complexCollection.vm b/ext/pojogen-maven-plugin/src/main/resources/complexCollection.vm
index beeee41..70262d9 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/complexCollection.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/complexCollection.vm
@@ -48,53 +48,13 @@ import javax.xml.datatype.Duration;
 #set ( $javaComplexType = $utility.getJavaType($complexType) )
 
 public interface $utility.capitalize($complexType.Name)Collection extends 
-    org.apache.olingo.ext.proxy.api.StruncturedCollectionQuery<$javaComplexType, ${javaComplexType}Collection, ${javaComplexType}Collection>, org.apache.olingo.ext.proxy.api.ComplexCollection<$javaComplexType> {
+    org.apache.olingo.ext.proxy.api.StructuredCollectionQuery<${javaComplexType}Collection>,
+    org.apache.olingo.ext.proxy.api.ComplexCollection<$javaComplexType, ${javaComplexType}Collection, ${javaComplexType}Collection> {
 #set( $functions = $utility.getFunctionsBoundTo($complexType.Name, true) )
 #set( $actions = $utility.getActionsBoundTo($complexType.Name, true) )
 #if( $functions.size() > 0 || $actions.size() > 0 )
-    Operations operations();
-
-    public interface Operations {
-
-    #foreach($operation in $functions)
-      @Operation(name = "$operation.Name",
-                    type = OperationType.FUNCTION,
-                    isComposable = $operation.Composable#if($operation.ReturnType),
-                    returnType = "#if( $operation.ReturnType.Collection )Collection(#end$operation.ReturnType.Type.FullQualifiedName.toString()#if( $operation.ReturnType.Collection ))#end"#end)
-      #if($operation.ReturnType)$utility.getJavaType($operation.ReturnType.Type, $operation.ReturnType.Collection)#{else}void#end $utility.uncapitalize($operation.Name)(
-      #if($operation.ParameterNames)
-        #set( $count = $operation.ParameterNames.size() )#*
-        *##foreach($paramName in $operation.ParameterNames)#*
-          *##set( $count = $count - 1 )#*
-          *##set( $param = $operation.getParameter($paramName) )#*
-          *##if( !$complexType.FullQualifiedName.equals($param.Type.FullQualifiedName) )#*
-        *#    @Parameter(name = "$param.Name", type = "#if( $param.Collection )Collection(#end$param.Type.FullQualifiedName.toString()#if( $param.Collection ))#end", nullable = $param.Nullable) $utility.getJavaType($param.Type, $param.Collection) $utility.uncapitalize($param.Name)#if( $count > 0 ), #end
-
-      #end
-      #end#*
-      *##end);
-
-    #end
-
-    #foreach($operation in $actions)
-      @Operation(name = "$operation.Name",
-                    type = OperationType.ACTION#if($operation.ReturnType),
-                    returnType = "#if( $operation.ReturnType.Collection )Collection(#end$operation.ReturnType.Type.FullQualifiedName.toString()#if( $operation.ReturnType.Collection ))#end"#end)
-      #if($operation.ReturnType)$utility.getJavaType($operation.ReturnType.Type, $operation.ReturnType.Collection)#{else}void#end $utility.uncapitalize($operation.Name)(
-      #if($operation.ParameterNames)
-        #set( $count = $operation.ParameterNames.size() )#*
-        *##foreach($paramName in $operation.ParameterNames)#*
-          *##set( $count = $count - 1 )#*
-          *##set( $param = $operation.getParameter($paramName) )#*
-          *##if( !$complexType.FullQualifiedName.equals($param.Type.FullQualifiedName) )#*
-        *#    @Parameter(name = "$param.Name", type = "#if( $param.Collection )Collection(#end$param.Type.FullQualifiedName.toString()#if( $param.Collection ))#end", nullable = $param.Nullable) $utility.getJavaType($param.Type, $param.Collection) $utility.uncapitalize($param.Name)#if( $count > 0 ), #end
-
-      #end
-      #end#*
-      *##end);
-
-    #end
-    }
+#set($structuredType = $complexType)
+#parse( "operation.vm" )
 #end
 
   Object getAnnotation(Class<? extends AbstractTerm> term);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/resources/complexType.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/complexType.vm b/ext/pojogen-maven-plugin/src/main/resources/complexType.vm
index a54938d..86da370 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/complexType.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/complexType.vm
@@ -44,4 +44,13 @@ import org.apache.olingo.commons.api.edm.geo.Polygon;
 //CHECKSTYLE:ON (Maven checkstyle)
 
 #parse( "${odataVersion}/complexType.vm" )
+
+#set( $functions = $utility.getFunctionsBoundTo($complexType.Name, false) )
+#set( $actions = $utility.getActionsBoundTo($complexType.Name, false) )
+#set( $inherited = $utility.justInheritedOperationsBoundTo($complexType) )
+#if( $inherited.size() > 0 || $functions.size() > 0 || $actions.size() > 0 )
+#set($structuredType = $complexType)
+#parse( "operation.vm" )
+#end
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/resources/container.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/container.vm b/ext/pojogen-maven-plugin/src/main/resources/container.vm
index 843ff88..939e1f5 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/container.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/container.vm
@@ -72,11 +72,35 @@ public interface $utility.capitalize($container.Name) extends PersistenceManager
   public interface Operations {
   #foreach($operation in $container.FunctionImports)
   #foreach($function in $operation.UnboundFunctions)
+    #if($function.ReturnType)#*
+      *##set($defaultType = $utility.getJavaType($function.ReturnType.Type, $function.ReturnType.Collection))#*
+      *##if(!($function.getReturnType().isCollection() || ${function.ReturnType.Type.Kind} == "ENTITY" || ${function.ReturnType.Type.Kind} == "COMPLEX" || $utility.isStreamType($function.ReturnType.Type)))#*
+        *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<$defaultType>")#*
+      *##else#*
+        *##if(${function.ReturnType.Type.Kind} == "ENTITY" || ${function.ReturnType.Type.Kind} == "COMPLEX")#*
+          *##if($function.getReturnType().isCollection())#*
+            *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredCollectionInvoker<$defaultType>")#*
+          *##{else}#*
+            *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredInvoker<$defaultType>")#*
+          *##end#*
+        *##{else}#*
+          *##if($function.getReturnType().isCollection())#*
+            *##set($returnType = "org.apache.olingo.ext.proxy.api.PrimitiveCollectionInvoker<$defaultType>")#*
+          *##{else}#*
+            *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<$defaultType>")#*
+          *##end#*
+        *##end#*
+      *##end#*
+    *##{else}#*
+      *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<Void>")#*
+    *##end
+
     @org.apache.olingo.ext.proxy.api.annotations.Operation(name = "$function.Name",
                     type = OperationType.FUNCTION,
                     isComposable = $function.Composable#if($function.ReturnType),
+                    #if($function.ReturnType)referenceType = ${defaultType.replaceAll("<.*>", "")}.class,#end
                     returnType = "#if( $function.ReturnType.Collection )Collection(#end$function.ReturnType.Type.FullQualifiedName.toString()#if( $function.ReturnType.Collection ))#end"#end)
-  #if($function.ReturnType)$utility.getJavaType($function.ReturnType.Type, $function.ReturnType.Collection)#{else}void#end $utility.uncapitalize($function.Name)(
+    $returnType $utility.uncapitalize($function.Name)(
     #if($function.ParameterNames)
       #set( $count = $function.ParameterNames.size() )#*
       *##foreach($paramName in $function.ParameterNames)#*
@@ -93,10 +117,34 @@ public interface $utility.capitalize($container.Name) extends PersistenceManager
   #foreach($operation in $container.ActionImports)
   #set( $action = $operation.UnboundAction )
   #if($action)
+    #if($action.ReturnType)#*
+      *##set($defaultType = $utility.getJavaType($action.ReturnType.Type, $action.ReturnType.Collection))#*
+      *##if(!($action.getReturnType().isCollection() || ${action.ReturnType.Type.Kind} == "ENTITY" || ${action.ReturnType.Type.Kind} == "COMPLEX" || $utility.isStreamType($action.ReturnType.Type)))#*
+        *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<$defaultType>")#*
+      *##else#*
+        *##if(${action.ReturnType.Type.Kind} == "ENTITY" || ${action.ReturnType.Type.Kind} == "COMPLEX")#*
+          *##if($action.getReturnType().isCollection())#*
+            *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredCollectionInvoker<$defaultType>")#*
+          *##{else}#*
+            *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredInvoker<$defaultType>")#*
+          *##end#*
+        *##{else}#*
+          *##if($action.getReturnType().isCollection())#*
+            *##set($returnType = "org.apache.olingo.ext.proxy.api.PrimitiveCollectionInvoker<$defaultType>")#*
+          *##{else}#*
+            *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<$defaultType>")#*
+          *##end#*
+        *##end#*
+      *##end#*
+    *##{else}#*
+      *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<Void>")#*
+    *##end
+
     @org.apache.olingo.ext.proxy.api.annotations.Operation(name = "$action.Name",
                     type = OperationType.ACTION#if($action.ReturnType),
+                    #if($action.ReturnType)referenceType = ${defaultType.replaceAll("<.*>", "")}.class,#end
                     returnType = "#if( $action.ReturnType.Collection )Collection(#end$action.ReturnType.Type.FullQualifiedName.toString()#if( $action.ReturnType.Collection ))#end"#end)
-  #if($action.ReturnType)$utility.getJavaType($action.ReturnType.Type, $action.ReturnType.Collection)#{else}void#end $utility.uncapitalize($action.Name)(
+    $returnType $utility.uncapitalize($action.Name)(
     #if($action.ParameterNames)
       #set( $count = $action.ParameterNames.size() )#*
       *##foreach($paramName in $action.ParameterNames)#*
@@ -112,13 +160,13 @@ public interface $utility.capitalize($container.Name) extends PersistenceManager
   #end
   }
 
-  <NE extends EntityType> NE newEntityInstance(Class<NE> ref);
+  <NE extends EntityType<?>> NE newEntityInstance(Class<NE> ref);
 
-  <T extends EntityType, NEC extends EntityCollection<T>> NEC newEntityCollection(Class<NEC> ref);
+  <T extends EntityType<?>, NEC extends EntityCollection<T, ?, ?>> NEC newEntityCollection(Class<NEC> ref);
 
-  <NE extends ComplexType> NE newComplexInstance(Class<NE> ref);
+  <NE extends ComplexType<?>> NE newComplexInstance(Class<NE> ref);
 
-  <T extends ComplexType, NEC extends ComplexCollection<T>> NEC newComplexCollection(Class<NEC> ref);
+  <T extends ComplexType<?>, NEC extends ComplexCollection<T, ?, ?>> NEC newComplexCollection(Class<NEC> ref);
 
   <T extends Serializable, NEC extends PrimitiveCollection<T>> NEC newPrimitiveCollection(Class<T> ref);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/resources/entityCollection.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/entityCollection.vm b/ext/pojogen-maven-plugin/src/main/resources/entityCollection.vm
index f8ea0df..bbab76f 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/entityCollection.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/entityCollection.vm
@@ -48,53 +48,13 @@ import javax.xml.datatype.Duration;
 #set ( $javaEntityType = $utility.getJavaType($entityType) )
 
 public interface $utility.capitalize($entityType.Name)Collection extends 
-    org.apache.olingo.ext.proxy.api.StruncturedCollectionQuery<$javaEntityType, ${javaEntityType}Collection, ${javaEntityType}Collection>, org.apache.olingo.ext.proxy.api.EntityCollection<$javaEntityType> {
+    org.apache.olingo.ext.proxy.api.StructuredCollectionQuery<${javaEntityType}Collection>,
+    org.apache.olingo.ext.proxy.api.EntityCollection<$javaEntityType, ${javaEntityType}Collection, ${javaEntityType}Collection> {
 #set( $functions = $utility.getFunctionsBoundTo($entityType.Name, true) )
 #set( $actions = $utility.getActionsBoundTo($entityType.Name, true) )
 #if( $functions.size() > 0 || $actions.size() > 0 )
-    Operations operations();
-
-    public interface Operations {
-
-    #foreach($operation in $functions)
-      @Operation(name = "$operation.Name",
-                    type = OperationType.FUNCTION,
-                    isComposable = $operation.Composable#if($operation.ReturnType),
-                    returnType = "#if( $operation.ReturnType.Collection )Collection(#end$operation.ReturnType.Type.FullQualifiedName.toString()#if( $operation.ReturnType.Collection ))#end"#end)
-      #if($operation.ReturnType)$utility.getJavaType($operation.ReturnType.Type, $operation.ReturnType.Collection)#{else}void#end $utility.uncapitalize($operation.Name)(
-      #if($operation.ParameterNames)
-        #set( $count = $operation.ParameterNames.size() )#*
-        *##foreach($paramName in $operation.ParameterNames)#*
-          *##set( $count = $count - 1 )#*
-          *##set( $param = $operation.getParameter($paramName) )#*
-          *##if( !$entityType.FullQualifiedName.equals($param.Type.FullQualifiedName) )#*
-        *#    @Parameter(name = "$param.Name", type = "#if( $param.Collection )Collection(#end$param.Type.FullQualifiedName.toString()#if( $param.Collection ))#end", nullable = $param.Nullable) $utility.getJavaType($param.Type, $param.Collection) $utility.uncapitalize($param.Name)#if( $count > 0 ), #end
-
-      #end
-      #end#*
-      *##end);
-
-    #end
-
-    #foreach($operation in $actions)
-      @Operation(name = "$operation.Name",
-                    type = OperationType.ACTION#if($operation.ReturnType),
-                    returnType = "#if( $operation.ReturnType.Collection )Collection(#end$operation.ReturnType.Type.FullQualifiedName.toString()#if( $operation.ReturnType.Collection ))#end"#end)
-      #if($operation.ReturnType)$utility.getJavaType($operation.ReturnType.Type, $operation.ReturnType.Collection)#{else}void#end $utility.uncapitalize($operation.Name)(
-      #if($operation.ParameterNames)
-        #set( $count = $operation.ParameterNames.size() )#*
-        *##foreach($paramName in $operation.ParameterNames)#*
-          *##set( $count = $count - 1 )#*
-          *##set( $param = $operation.getParameter($paramName) )#*
-          *##if( !$entityType.FullQualifiedName.equals($param.Type.FullQualifiedName) )#*
-        *#    @Parameter(name = "$param.Name", type = "#if( $param.Collection )Collection(#end$param.Type.FullQualifiedName.toString()#if( $param.Collection ))#end", nullable = $param.Nullable) $utility.getJavaType($param.Type, $param.Collection) $utility.uncapitalize($param.Name)#if( $count > 0 ), #end
-
-      #end
-      #end#*
-      *##end);
-
-    #end
-    }
+#set($structuredType = $entityType)
+#parse( "operation.vm" )
 #end
 
   Object getAnnotation(Class<? extends AbstractTerm> term);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/resources/entitySet.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/entitySet.vm b/ext/pojogen-maven-plugin/src/main/resources/entitySet.vm
index 4afefac..ba1d353 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/entitySet.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/entitySet.vm
@@ -57,5 +57,14 @@ import javax.xml.datatype.Duration;
 
 @org.apache.olingo.ext.proxy.api.annotations.EntitySet(name = "$entitySet.Name", container = "$container.FullQualifiedName.toString()")
 public interface $utility.capitalize($entitySet.Name) 
-  extends org.apache.olingo.ext.proxy.api.EntitySetQuery<$javaEntityType, ${javaEntityType}Collection, $utility.capitalize($entitySet.Name)>, AbstractEntitySet<$javaEntityType, $type, ${javaEntityType}Collection> {
+  extends org.apache.olingo.ext.proxy.api.EntitySet<$javaEntityType, ${javaEntityType}Collection>, 
+  org.apache.olingo.ext.proxy.api.StructuredCollectionQuery<$utility.capitalize($entitySet.Name)>,
+  AbstractEntitySet<$javaEntityType, $type, ${javaEntityType}Collection> {
+
+#set( $functions = $utility.getFunctionsBoundTo("${container.Namespace}.${entitySet.Name}", false) )
+#set( $actions = $utility.getActionsBoundTo("${container.Namespace}.${entitySet.Name}", false) )
+#if( $functions.size() > 0 || $actions.size() > 0 )
+#set($structuredType = $entitySet.EntityType)
+#parse( "operation.vm" )
+#end
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/resources/entityType.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/entityType.vm b/ext/pojogen-maven-plugin/src/main/resources/entityType.vm
index 42c7549..b87709b 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/entityType.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/entityType.vm
@@ -59,7 +59,9 @@ import org.apache.olingo.commons.api.edm.geo.Polygon;
         isAbstract = $entityType.Abstract#if($entityType.getBaseType()),
         baseType = "$entityType.getBaseType().getFullQualifiedName().toString()"#end)
 public interface $utility.capitalize($entityType.Name) 
-  extends org.apache.olingo.ext.proxy.api.EntityType,org.apache.olingo.ext.proxy.api.Annotatable,#if( $entityType.getBaseType() )$utility.getJavaType($entityType.getBaseType())#{else}org.apache.olingo.ext.proxy.api.SingleQuery<$utility.capitalize($entityType.Name)>#end#{if}( $entityType.isOpenType() ),AbstractOpenType#end {
+  extends org.apache.olingo.ext.proxy.api.Annotatable,
+  #if( $entityType.getBaseType() )$utility.getJavaType($entityType.getBaseType())#{else}org.apache.olingo.ext.proxy.api.EntityType<$utility.capitalize($entityType.Name)>, org.apache.olingo.ext.proxy.api.StructuredQuery<$utility.capitalize($entityType.Name)>#end
+  #{if}( $entityType.isOpenType() ),AbstractOpenType#end {
 
 #if( $entityType.getBaseType() )
   @Override
@@ -137,52 +139,8 @@ public interface $utility.capitalize($entityType.Name)
 #set( $actions = $utility.getActionsBoundTo($entityType.Name, false) )
 #set( $inherited = $utility.justInheritedOperationsBoundTo($entityType) )
 #if( $inherited.size() > 0 || $functions.size() > 0 || $actions.size() > 0 )
-    #if($inherited.size() > 0)
-    @Override
-    #end
-    Operations operations();
-
-    interface Operations #if($inherited.size() > 0)
-           extends ${utility.getJavaType($entityType.getBaseType())}.Operations#end{
-    #foreach($operation in $functions)
-      @org.apache.olingo.ext.proxy.api.annotations.Operation(name = "$operation.Name",
-                    type = OperationType.FUNCTION,
-                    isComposable = $operation.Composable#if($operation.ReturnType),
-                    returnType = "#if( $operation.ReturnType.Collection )Collection(#end$operation.ReturnType.Type.FullQualifiedName.toString()#if( $operation.ReturnType.Collection ))#end"#end)
-      #if($operation.ReturnType)$utility.getJavaType($operation.ReturnType.Type, $operation.ReturnType.Collection)#{else}void#end $utility.uncapitalize($operation.Name)(
-      #if($operation.ParameterNames)
-        #set( $count = $operation.ParameterNames.size() )#*
-        *##foreach($paramName in $operation.ParameterNames)#*
-          *##set( $count = $count - 1 )#*
-          *##set( $param = $operation.getParameter($paramName) )#*
-          *##if( !$entityType.FullQualifiedName.equals($param.Type.FullQualifiedName) )#*
-        *#    @Parameter(name = "$param.Name", type = "#if( $param.Collection )Collection(#end$param.Type.FullQualifiedName.toString()#if( $param.Collection ))#end", nullable = $param.Nullable) $utility.getJavaType($param.Type, $param.Collection) $utility.uncapitalize($param.Name)#if( $count > 0 ), #end
-
-      #end
-      #end#*
-      *##end);
-
-    #end
-
-    #foreach($operation in $actions)
-      @org.apache.olingo.ext.proxy.api.annotations.Operation(name = "$operation.Name",
-                    type = OperationType.ACTION#if($operation.ReturnType),
-                    returnType = "#if( $operation.ReturnType.Collection )Collection(#end$operation.ReturnType.Type.FullQualifiedName.toString()#if( $operation.ReturnType.Collection ))#end"#end)
-      #if($operation.ReturnType)$utility.getJavaType($operation.ReturnType.Type, $operation.ReturnType.Collection)#{else}void#end $utility.uncapitalize($operation.Name)(
-      #if($operation.ParameterNames)
-        #set( $count = $operation.ParameterNames.size() )#*
-        *##foreach($paramName in $operation.ParameterNames)#*
-          *##set( $count = $count - 1 )#*
-          *##set( $param = $operation.getParameter($paramName) )#*
-          *##if( !$entityType.FullQualifiedName.equals($param.Type.FullQualifiedName) )#*
-        *#    @Parameter(name = "$param.Name", type = "#if( $param.Collection )Collection(#end$param.Type.FullQualifiedName.toString()#if( $param.Collection ))#end", nullable = $param.Nullable) $utility.getJavaType($param.Type, $param.Collection) $utility.uncapitalize($param.Name)#if( $count > 0 ), #end
-
-      #end
-      #end#*
-      *##end);
-
-    #end
-    }
+#set($structuredType = $entityType)
+#parse( "operation.vm" )
 #end
 
     Annotations annotations();
@@ -233,7 +191,9 @@ public interface $utility.capitalize($entityType.Name)
 
     @org.apache.olingo.ext.proxy.api.annotations.EntitySet(name = "$property.Name", contained = true)
     interface $utility.capitalize($property.Name) 
-      extends org.apache.olingo.ext.proxy.api.EntitySetQuery<$javaEntityType, ${javaEntityType}Collection, $utility.capitalize($property.Name)>, AbstractEntitySet<$javaEntityType, $type, ${javaEntityType}Collection> {
+      extends org.apache.olingo.ext.proxy.api.EntitySet<$javaEntityType, ${javaEntityType}Collection>, 
+      org.apache.olingo.ext.proxy.api.StructuredCollectionQuery<$utility.capitalize($property.Name)>,
+      AbstractEntitySet<$javaEntityType, $type, ${javaEntityType}Collection> {
     }
 
   #end

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/resources/operation.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/operation.vm b/ext/pojogen-maven-plugin/src/main/resources/operation.vm
new file mode 100644
index 0000000..3576357
--- /dev/null
+++ b/ext/pojogen-maven-plugin/src/main/resources/operation.vm
@@ -0,0 +1,112 @@
+#*
+ * 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.
+ *#
+    #if($inherited.size() > 0)
+    @Override
+    #end
+    Operations operations();
+
+    interface Operations #if($inherited.size() > 0)
+           extends ${utility.getJavaType($structuredType.getBaseType())}.Operations#end{
+    #foreach($operation in $functions)
+      #if($operation.ReturnType)#*
+        *##set($defaultType = $utility.getJavaType($operation.ReturnType.Type, $operation.ReturnType.Collection))#*
+        *##if(!($operation.getReturnType().isCollection() || ${operation.ReturnType.Type.Kind} == "ENTITY" || ${operation.ReturnType.Type.Kind} == "COMPLEX" || $utility.isStreamType($operation.ReturnType.Type)))#*
+          *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<$defaultType>")#*
+        *##else#*
+          *##if(${operation.ReturnType.Type.Kind} == "ENTITY" || ${operation.ReturnType.Type.Kind} == "COMPLEX")#*
+            *##if($operation.getReturnType().isCollection())#*
+              *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredCollectionInvoker<$defaultType>")#*
+            *##{else}#*
+              *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredInvoker<$defaultType>")#*
+            *##end#*
+          *##{else}#*
+            *##if($operation.getReturnType().isCollection())#*
+              *##set($returnType = "org.apache.olingo.ext.proxy.api.PrimitiveCollectionInvoker<$defaultType>")#*
+            *##{else}#*
+              *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<$defaultType>")#*
+            *##end#*
+          *##end#*
+        *##end#*
+      *##{else}#*
+        *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<Void>")#*
+      *##end
+
+      @org.apache.olingo.ext.proxy.api.annotations.Operation(name = "$operation.Name",
+                    type = OperationType.FUNCTION,
+                    isComposable = $operation.Composable#if($operation.ReturnType),
+                    #if($operation.ReturnType)referenceType = ${defaultType.replaceAll("<.*>", "")}.class,#end
+                    returnType = "#if( $operation.ReturnType.Collection )Collection(#end$operation.ReturnType.Type.FullQualifiedName.toString()#if( $operation.ReturnType.Collection ))#end"#end)
+      $returnType $utility.uncapitalize($operation.Name)(
+      #if($operation.ParameterNames)
+        #set( $count = $operation.ParameterNames.size() )#*
+        *##foreach($paramName in $operation.ParameterNames)#*
+          *##set( $count = $count - 1 )#*
+          *##set( $param = $operation.getParameter($paramName) )#*
+          *##if( !$structuredType.FullQualifiedName.equals($param.Type.FullQualifiedName) )#*
+        *#    @Parameter(name = "$param.Name", type = "#if( $param.Collection )Collection(#end$param.Type.FullQualifiedName.toString()#if( $param.Collection ))#end", nullable = $param.Nullable) $utility.getJavaType($param.Type, $param.Collection) $utility.uncapitalize($param.Name)#if( $count > 0 ), #end
+
+      #end
+      #end#*
+      *##end);
+
+    #end
+
+    #foreach($operation in $actions)
+      #if($operation.ReturnType)#*
+        *##set($defaultType = $utility.getJavaType($operation.ReturnType.Type, $operation.ReturnType.Collection))#*
+        *##if(!($operation.getReturnType().isCollection() || ${operation.ReturnType.Type.Kind} == "ENTITY" || ${operation.ReturnType.Type.Kind} == "COMPLEX" || $utility.isStreamType($operation.ReturnType.Type)))#*
+          *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<$defaultType>")#*
+        *##else#*
+          *##if(${operation.ReturnType.Type.Kind} == "ENTITY" || ${operation.ReturnType.Type.Kind} == "COMPLEX")#*
+            *##if($operation.getReturnType().isCollection())#*
+              *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredCollectionInvoker<$defaultType>")#*
+            *##{else}#*
+              *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredInvoker<$defaultType>")#*
+            *##end#*
+          *##{else}#*
+            *##if($operation.getReturnType().isCollection())#*
+              *##set($returnType = "org.apache.olingo.ext.proxy.api.PrimitiveCollectionInvoker<$defaultType>")#*
+            *##{else}#*
+              *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<$defaultType>")#*
+            *##end#*
+          *##end#*
+        *##end#*
+      *##{else}#*
+        *##set($returnType = "org.apache.olingo.ext.proxy.api.Invoker<Void>")#*
+      *##end
+
+      @org.apache.olingo.ext.proxy.api.annotations.Operation(name = "$operation.Name",
+                    type = OperationType.ACTION#if($operation.ReturnType),
+                    #if($operation.ReturnType)referenceType = ${defaultType.replaceAll("<.*>", "")}.class,#end
+                    returnType = "#if( $operation.ReturnType.Collection )Collection(#end$operation.ReturnType.Type.FullQualifiedName.toString()#if( $operation.ReturnType.Collection ))#end"#end)
+      $returnType $utility.uncapitalize($operation.Name)(
+      #if($operation.ParameterNames)
+        #set( $count = $operation.ParameterNames.size() )#*
+        *##foreach($paramName in $operation.ParameterNames)#*
+          *##set( $count = $count - 1 )#*
+          *##set( $param = $operation.getParameter($paramName) )#*
+          *##if( !$structuredType.FullQualifiedName.equals($param.Type.FullQualifiedName) )#*
+        *#    @Parameter(name = "$param.Name", type = "#if( $param.Collection )Collection(#end$param.Type.FullQualifiedName.toString()#if( $param.Collection ))#end", nullable = $param.Nullable) $utility.getJavaType($param.Type, $param.Collection) $utility.uncapitalize($param.Name)#if( $count > 0 ), #end
+
+      #end
+      #end#*
+      *##end);
+
+    #end
+    }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/resources/v30/complexType.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/v30/complexType.vm b/ext/pojogen-maven-plugin/src/main/resources/v30/complexType.vm
index 6fa23f4..075d79c 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/v30/complexType.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/v30/complexType.vm
@@ -19,7 +19,7 @@
 @org.apache.olingo.ext.proxy.api.annotations.Namespace("$namespace")
 @org.apache.olingo.ext.proxy.api.annotations.ComplexType(name = "$complexType.Name")
 public interface $utility.capitalize($complexType.Name) 
-    extends org.apache.olingo.ext.proxy.api.ComplexType,#if($complexType.getBaseType())$utility.getJavaType($complexType.getBaseType().getFullQualifiedName().toString())#{else}org.apache.olingo.ext.proxy.api.SingleQuery<$utility.capitalize($complexType.Name)>#end {
+    extends #if($complexType.getBaseType())$utility.getJavaType($complexType.getBaseType().getFullQualifiedName().toString())#{else}org.apache.olingo.ext.proxy.api.ComplexType<$utility.capitalize($complexType.Name)>, org.apache.olingo.ext.proxy.api.StructuredQuery<$utility.capitalize($complexType.Name)>#end {
 
 #if( $entityType.getBaseType() )
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/ext/pojogen-maven-plugin/src/main/resources/v40/complexType.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/v40/complexType.vm b/ext/pojogen-maven-plugin/src/main/resources/v40/complexType.vm
index ce4b0fc..1717564 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/v40/complexType.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/v40/complexType.vm
@@ -22,7 +22,7 @@
         isAbstract = $complexType.Abstract#if($complexType.getBaseType()),
         baseType = "$complexType.getBaseType().getFullQualifiedName().toString()"#end)
 public interface $utility.capitalize($complexType.Name) 
-    extends org.apache.olingo.ext.proxy.api.ComplexType,#if($complexType.getBaseType())$utility.getJavaType($complexType.getBaseType().getFullQualifiedName().toString())#{else}org.apache.olingo.ext.proxy.api.SingleQuery<$utility.capitalize($complexType.Name)>#{end}#if( $complexType.isOpenType() ),AbstractOpenType#{end} {
+    extends #if($complexType.getBaseType())$utility.getJavaType($complexType.getBaseType().getFullQualifiedName().toString())#{else}org.apache.olingo.ext.proxy.api.ComplexType<$utility.capitalize($complexType.Name)>, org.apache.olingo.ext.proxy.api.StructuredQuery<$utility.capitalize($complexType.Name)>#{end}#if( $complexType.isOpenType() ),AbstractOpenType#{end} {
 
 #if( $entityType.getBaseType() )
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java
index aaadccd..5a13532 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ActionOverloadingTestITCase.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3;
 
 import static org.junit.Assert.assertEquals;
@@ -52,12 +53,12 @@ public class ActionOverloadingTestITCase extends AbstractTestITCase {
   public void retrieveProduct() {
     final DefaultContainer aocontainer = getContainer();
 
-    int res = aocontainer.operations().retrieveProduct();
+    int res = aocontainer.operations().retrieveProduct().execute();
     assertEquals(-10, res);
 
     service.getContext().detachAll();
 
-    res = aocontainer.getProduct().getByKey(-10).operations().retrieveProduct();
+    res = aocontainer.getProduct().getByKey(-10).operations().retrieveProduct().execute();
     assertEquals(-10, res);
 
     service.getContext().detachAll();
@@ -66,7 +67,7 @@ public class ActionOverloadingTestITCase extends AbstractTestITCase {
     key.setOrderId(-10);
     key.setProductId(-10);
 
-    res = aocontainer.getOrderLine().getByKey(key).operations().retrieveProduct();
+    res = aocontainer.getOrderLine().getByKey(key).operations().retrieveProduct().execute();
     assertEquals(-10, res);
   }
 
@@ -83,7 +84,7 @@ public class ActionOverloadingTestITCase extends AbstractTestITCase {
     empl.getPersonId();
     int salary = empl.getSalary();
 
-    ecoll.operations().increaseSalaries(5);
+    ecoll.operations().increaseSalaries(5).execute();
 
     // the invoke above changed the local entities, re-read
     service.getContext().detachAll();
@@ -101,7 +102,7 @@ public class ActionOverloadingTestITCase extends AbstractTestITCase {
     sempl.getPersonId();
     salary = sempl.getSalary();
 
-    secoll.operations().increaseSalaries(5);
+    secoll.operations().increaseSalaries(5).execute();
 
     // the invoke above changed the local entities, re-read
     service.getContext().detachAll();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
index 62c2a73..3645bf2 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java
index ecbfca0..3b0e396 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntityRetrieveTestITCase.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3;
 
 //CHECKSTYLE:OFF (Maven checkstyle)

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntitySetTestITCase.java
index aa3a66c..14b7c1c 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntitySetTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/EntitySetTestITCase.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3;
 
 import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Car;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/FilterTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/FilterTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/FilterTestITCase.java
index aea7c0d..dc9d615 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/FilterTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/FilterTestITCase.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3;
 
 import org.apache.olingo.ext.proxy.api.Sort;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/InvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/InvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/InvokeTestITCase.java
index c278abf..62c3d60 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/InvokeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/InvokeTestITCase.java
@@ -56,11 +56,12 @@ public class InvokeTestITCase extends AbstractTestITCase {
   @Test
   public void getWithNoParams() {
     // 1. primitive result
-    final String string = container.operations().getPrimitiveString();
+    final String string = container.operations().getPrimitiveString().execute();
     assertEquals("Foo", string);
 
     // 2. complex collection result
-    final ContactDetailsCollection details = container.operations().entityProjectionReturnsCollectionOfComplexTypes();
+    final ContactDetailsCollection details =
+            container.operations().entityProjectionReturnsCollectionOfComplexTypes().execute();
     assertFalse(details.isEmpty());
     for (ContactDetails detail : details) {
       assertNotNull(detail);
@@ -71,10 +72,10 @@ public class InvokeTestITCase extends AbstractTestITCase {
   @Test
   public void getWithParam() {
     // 1. primitive result
-    assertEquals(155, container.operations().getArgumentPlusOne(154), 0);
+    assertEquals(155, container.operations().getArgumentPlusOne(154).execute(), 0);
 
     // 2. entity collection result
-    final CustomerCollection customers = container.operations().getSpecificCustomer(StringUtils.EMPTY);
+    final CustomerCollection customers = container.operations().getSpecificCustomer(StringUtils.EMPTY).execute();
     assertNotNull(customers);
     assertFalse(customers.isEmpty());
     final Set<Integer> customerIds = new HashSet<Integer>(customers.size());
@@ -106,7 +107,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
 
     try {
       // 1. invoke action bound to the employee just created
-      employee.operations().sack();
+      employee.operations().sack().execute();
 
       // 2. check that invoked action has effectively run
       employee = container.getPerson().getByKey(id, Employee.class).load();
@@ -131,7 +132,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
     }
     assertFalse(preSalaries.isEmpty());
 
-    employees.operations().increaseSalaries(1);
+    employees.operations().increaseSalaries(1).execute();
 
     employees = container.getPerson().execute(EmployeeCollection.class);
     assertFalse(employees.isEmpty());
@@ -172,7 +173,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
       newDimensions.setHeight(BigDecimal.ONE);
       newDimensions.setWidth(BigDecimal.ONE);
 
-      product.operations().changeProductDimensions(newDimensions);
+      product.operations().changeProductDimensions(newDimensions).execute();
 
       // 2. check that invoked action has effectively run
       product = container.getProduct().getByKey(id).load();
@@ -224,7 +225,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
 
       // 1. invoke action bound to the computer detail just created
       computerDetail.operations().resetComputerDetailsSpecifications(
-              cds, new Timestamp(Calendar.getInstance().getTimeInMillis()));
+              cds, new Timestamp(Calendar.getInstance().getTimeInMillis())).execute();
 
       // 2. check that invoked action has effectively run
       computerDetail = container.getComputerDetail().getByKey(id).load();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/MediaEntityTestITCase.java
index d4ded24..d3d74cd 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/MediaEntityTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/MediaEntityTestITCase.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java
index 5b227e1..aa5e73a 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PrimitiveKeysTestITCase.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PropertyTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PropertyTestITCase.java
index 0041103..9778ba3 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PropertyTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PropertyTestITCase.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3;
 
 import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Driver;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/Service.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/Service.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/Service.java
index babc2fe..2858233 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/Service.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/Service.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3.actionoverloading;
 
 import java.util.HashMap;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoCollectionTypesSet.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoCollectionTypesSet.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoCollectionTypesSet.java
index 38c0e13..046b4b9 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoCollectionTypesSet.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoCollectionTypesSet.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice;
 
 //CHECKSTYLE:OFF (Maven checkstyle)
@@ -26,5 +27,8 @@ import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
 
 @org.apache.olingo.ext.proxy.api.annotations.EntitySet(name = "AllGeoCollectionTypesSet", container = "Microsoft.Test.OData.Services.AstoriaDefaultService.DefaultContainer")
 public interface AllGeoCollectionTypesSet 
-  extends org.apache.olingo.ext.proxy.api.EntitySetQuery<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypes, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypesCollection, AllGeoCollectionTypesSet>, AbstractEntitySet<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypes, java.lang.Integer, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypesCollection> {
+  extends org.apache.olingo.ext.proxy.api.EntitySet<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypes, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypesCollection>, 
+  org.apache.olingo.ext.proxy.api.StructuredCollectionQuery<AllGeoCollectionTypesSet>,
+  AbstractEntitySet<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypes, java.lang.Integer, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialCollectionTypesCollection> {
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoTypesSet.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoTypesSet.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoTypesSet.java
index edb78e3..67fbe0d 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoTypesSet.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/AllGeoTypesSet.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice;
 
 //CHECKSTYLE:OFF (Maven checkstyle)
@@ -26,5 +27,8 @@ import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
 
 @org.apache.olingo.ext.proxy.api.annotations.EntitySet(name = "AllGeoTypesSet", container = "Microsoft.Test.OData.Services.AstoriaDefaultService.DefaultContainer")
 public interface AllGeoTypesSet 
-  extends org.apache.olingo.ext.proxy.api.EntitySetQuery<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypes, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypesCollection, AllGeoTypesSet>, AbstractEntitySet<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypes, java.lang.Integer, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypesCollection> {
+  extends org.apache.olingo.ext.proxy.api.EntitySet<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypes, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypesCollection>, 
+  org.apache.olingo.ext.proxy.api.StructuredCollectionQuery<AllGeoTypesSet>,
+  AbstractEntitySet<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypes, java.lang.Integer, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.AllSpatialTypesCollection> {
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/abb47659/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/Car.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/Car.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/Car.java
index aa100bb..86efac2 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/Car.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/actionoverloading/microsoft/test/odata/services/astoriadefaultservice/Car.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice;
 
 //CHECKSTYLE:OFF (Maven checkstyle)
@@ -26,5 +27,8 @@ import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
 
 @org.apache.olingo.ext.proxy.api.annotations.EntitySet(name = "Car", container = "Microsoft.Test.OData.Services.AstoriaDefaultService.DefaultContainer")
 public interface Car 
-  extends org.apache.olingo.ext.proxy.api.EntitySetQuery<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Car, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.CarCollection, Car>, AbstractEntitySet<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Car, java.lang.Integer, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.CarCollection> {
+  extends org.apache.olingo.ext.proxy.api.EntitySet<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Car, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.CarCollection>, 
+  org.apache.olingo.ext.proxy.api.StructuredCollectionQuery<Car>,
+  AbstractEntitySet<org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.Car, java.lang.Integer, org.apache.olingo.fit.proxy.v3.actionoverloading.microsoft.test.odata.services.astoriadefaultservice.types.CarCollection> {
+
 }