diff --git a/ext/client-proxy-android/pom.xml b/ext/client-proxy-android/pom.xml
new file mode 100644
index 000000000..b8c8027e4
--- /dev/null
+++ b/ext/client-proxy-android/pom.xml
@@ -0,0 +1,96 @@
+
+
+
+ 4.0.0
+
+ olingo-client-proxy-android
+ jar
+ ${project.artifactId}
+
+
+ org.apache.olingo
+ olingo-ext
+ 0.1.0-SNAPSHOT
+ ..
+
+
+
+
+ org.apache.olingo
+ olingo-client-proxy
+ ${project.version}
+ true
+
+
+
+
+
+
+ org.sonatype.plugins
+ jarjar-maven-plugin
+ true
+
+
+ package
+
+ jarjar
+
+
+
+ org.apache.olingo:olingo-client-proxy-android
+ org.apache.olingo:olingo-client-proxy
+ org.apache.olingo:olingo-client-core-android
+ org.apache.olingo:olingo-client-core
+ org.apache.olingo:olingo-client-api
+ org.apache.olingo:olingo-commons-api
+ org.apache.commons:commons-lang3
+ org.slf4j:slf4j-api
+ commons-io:commons-io
+ commons-beanutils:commons-beanutils
+ org.apache.httpcomponents:httpclient
+ org.apache.httpcomponents:httpcore
+ commons-logging:commons-logging
+ org.apache.olingo:olingo-commons-core
+ commons-codec:commons-codec
+ com.fasterxml.jackson.core:jackson-core
+ com.fasterxml.jackson.core:jackson-databind
+ com.fasterxml.jackson.core:jackson-annotations
+ com.fasterxml.jackson.dataformat:jackson-dataformat-xml
+ com.fasterxml.jackson.module:jackson-module-jaxb-annotations
+ org.codehaus.woodstox:stax2-api
+ javax.xml.stream:stax-api
+ com.fasterxml:aalto-xml
+
+
+
+ javax.xml.stream.**
+ org.apache.olingo.javax.xml.stream.@1
+
+
+
+
+
+
+
+
+
diff --git a/ext/client-proxy/pom.xml b/ext/client-proxy/pom.xml
index 827e7e9b1..bda3379d4 100644
--- a/ext/client-proxy/pom.xml
+++ b/ext/client-proxy/pom.xml
@@ -51,7 +51,7 @@
commons-beanutils
- commons-beanutils-core
+ commons-beanutils
commons-logging
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractAnnotatable.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Annotatable.java
similarity index 95%
rename from ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractAnnotatable.java
rename to ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Annotatable.java
index b0a1f4ff3..08af72be5 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractAnnotatable.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Annotatable.java
@@ -21,7 +21,7 @@ package org.apache.olingo.ext.proxy.api;
import java.io.Serializable;
import java.util.Collection;
-public interface AbstractAnnotatable extends Serializable {
+public interface Annotatable extends Serializable {
void addAnnotation(Class extends AbstractTerm> term, Object value);
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/BatchStreamManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForNavigationProperty.java
similarity index 63%
rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/BatchStreamManager.java
rename to ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForNavigationProperty.java
index 8caaf7a4d..ac57ee935 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/BatchStreamManager.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForNavigationProperty.java
@@ -16,19 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.olingo.client.api.communication.request.batch.v4;
+package org.apache.olingo.ext.proxy.api.annotations;
-/**
- * Batch request payload management.
- */
-public interface BatchStreamManager
- extends org.apache.olingo.client.api.communication.request.batch.BatchStreamManager {
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface AnnotationsForNavigationProperty {
+
+ String name();
+
+ String type();
- /**
- * Gets an outside update batch item instance. An outside update item can be submitted embedded into a batch request
- * only.
- *
- * @return ODataOutsideUpdate instance.
- */
- ODataOutsideUpdate addOutsideUpdate();
}
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/BatchStreamManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForProperty.java
similarity index 69%
rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/BatchStreamManager.java
rename to ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForProperty.java
index 0dd5bfbe1..1e317b2d4 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/BatchStreamManager.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForProperty.java
@@ -16,11 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.olingo.client.api.communication.request.batch.v3;
+package org.apache.olingo.ext.proxy.api.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface AnnotationsForProperty {
+
+ String name();
+
+ String type();
-/**
- * Batch request payload management.
- */
-public interface BatchStreamManager
- extends org.apache.olingo.client.api.communication.request.batch.BatchStreamManager {
}
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 2ce424a17..09b443b5a 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
@@ -35,12 +35,17 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
+import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
+import org.apache.olingo.client.api.http.HttpMethod;
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.EntityContainerFactory;
import org.apache.olingo.ext.proxy.api.OperationType;
@@ -156,6 +161,25 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
handler);
}
+ @SuppressWarnings("unchecked")
+ private Class getResultReference(final EdmReturnType returnType) {
+ Class result;
+
+ if (returnType == null) {
+ result = (Class) ODataNoContent.class;
+ } else {
+ if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
+ result = (Class) CommonODataEntitySet.class;
+ } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
+ result = (Class) CommonODataEntity.class;
+ } else {
+ result = (Class) CommonODataProperty.class;
+ }
+ }
+
+ return result;
+ }
+
protected Object invokeOperation(
final Operation annotation,
final Method method,
@@ -193,7 +217,11 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
// 3. invoke
final ODataInvokeResult result = client.getInvokeRequestFactory().getInvokeRequest(
- target, edmOperation, parameterValues).execute().getBody();
+ edmOperation instanceof EdmFunction ? HttpMethod.GET : HttpMethod.POST,
+ target,
+ getResultReference(edmOperation.getReturnType()),
+ parameterValues).
+ execute().getBody();
// 4. process invoke result
if (StringUtils.isBlank(annotation.returnType())) {
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
index 3a858951a..5f04408e6 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
@@ -26,6 +26,8 @@ import java.lang.reflect.Type;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
@@ -66,6 +68,12 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
protected Object internal;
+ private final Map propAnnotatableHandlers =
+ new HashMap();
+
+ private final Map navPropAnnotatableHandlers =
+ new HashMap();
+
protected AbstractStructuredInvocationHandler(
final CommonEdmEnabledODataClient> client,
final Class> typeRef,
@@ -91,6 +99,10 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
this.entityHandler = entityHandler == this ? null : entityHandler;
}
+ public Object getInternal() {
+ return internal;
+ }
+
public EntityInvocationHandler getEntityHandler() {
return entityHandler == null
? this instanceof EntityInvocationHandler
@@ -126,6 +138,13 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
Thread.currentThread().getContextClassLoader(),
new Class>[] {returnType},
ComplexFactoryInvocationHandler.getInstance(getEntityHandler(), this));
+ } else if ("annotations".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
+ final Class> returnType = method.getReturnType();
+
+ return Proxy.newProxyInstance(
+ Thread.currentThread().getContextClassLoader(),
+ new Class>[] {returnType},
+ AnnotatationsInvocationHandler.getInstance(getEntityHandler(), this));
} else if (method.getName().startsWith("get")) {
// Assumption: for each getter will always exist a setter and viceversa.
// get method annotation and check if it exists as expected
@@ -222,7 +241,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
null,
((ODataInlineEntity) link).getEntity(),
property.targetContainer(),
- client.getURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(),
+ client.newURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(),
type,
false);
} else if (link instanceof ODataInlineEntitySet) {
@@ -259,7 +278,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
uri,
res.getBody(),
property.targetContainer(),
- client.getURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(),
+ client.newURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(),
type,
res.getETag(),
true);
@@ -269,18 +288,6 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
return navPropValue;
}
- protected abstract Object getPropertyValue(final String name, final Type type);
-
- public void addAdditionalProperty(final String name, final Object value) {
- addPropertyChanges(name, value);
- attach(AttachedEntityStatus.CHANGED);
- }
-
- public void removeAdditionalProperty(final String name) {
- removePropertyChanges(name);
- attach(AttachedEntityStatus.CHANGED);
- }
-
public Object getAdditionalProperty(final String name) {
return getPropertyValue(name, null);
}
@@ -316,13 +323,31 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
addLinkChanges(property, value);
}
+ public Map getPropAnnotatableHandlers() {
+ return propAnnotatableHandlers;
+ }
+
+ public void putPropAnnotatableHandler(final String propName, final AnnotatableInvocationHandler handler) {
+ propAnnotatableHandlers.put(propName, handler);
+ }
+
+ public Map getNavPropAnnotatableHandlers() {
+ return navPropAnnotatableHandlers;
+ }
+
+ public void putNavPropAnnotatableHandler(final String navPropName, final AnnotatableInvocationHandler handler) {
+ navPropAnnotatableHandlers.put(navPropName, handler);
+ }
+
protected abstract void setPropertyValue(final Property property, final Object value);
- protected abstract void addPropertyChanges(final String name, final Object value);
-
- protected abstract void removePropertyChanges(final String name);
-
protected abstract void addLinkChanges(final NavigationProperty navProp, final Object value);
+ protected abstract Object getPropertyValue(final String name, final Type type);
+
+ public abstract void addAdditionalProperty(final String name, final Object value);
+
+ public abstract void removeAdditionalProperty(final String name);
+
public abstract boolean isChanged();
}
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
new file mode 100644
index 000000000..c0a4e539c
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java
@@ -0,0 +1,180 @@
+/*
+ * 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.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
+import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
+import org.apache.olingo.ext.proxy.api.AbstractTerm;
+import org.apache.olingo.ext.proxy.api.Annotatable;
+import org.apache.olingo.ext.proxy.api.annotations.Namespace;
+import org.apache.olingo.ext.proxy.api.annotations.Term;
+import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
+import org.apache.olingo.ext.proxy.utils.CoreUtils;
+
+public class AnnotatableInvocationHandler extends AbstractInvocationHandler implements Annotatable {
+
+ private static final long serialVersionUID = 3111228269617223332L;
+
+ private final String propName;
+
+ private final String navPropName;
+
+ private final EntityInvocationHandler entityHandler;
+
+ private final AbstractStructuredInvocationHandler targetHandler;
+
+ private final Map, Object> annotations =
+ new HashMap, Object>();
+
+ public AnnotatableInvocationHandler(
+ final CommonEdmEnabledODataClient> client,
+ final EntityContainerInvocationHandler containerHandler,
+ final String propName,
+ final String navPropName,
+ final EntityInvocationHandler entityHandler,
+ final AbstractStructuredInvocationHandler targetHandler) {
+
+ super(client, containerHandler);
+
+ this.propName = propName;
+ this.navPropName = navPropName;
+ this.entityHandler = entityHandler;
+ this.targetHandler = targetHandler;
+ }
+
+ @Override
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+ return invokeSelfMethod(method, args);
+ }
+
+ public Map, Object> getAnnotations() {
+ return annotations;
+ }
+
+ private List internalAnnotations() {
+ List result = Collections.emptyList();
+
+ if (entityHandler.getEntity() instanceof ODataEntity) {
+ if (targetHandler.getInternal() instanceof ODataEntity) {
+ result = propName == null
+ ? ((org.apache.olingo.commons.api.domain.v4.ODataLink) ((ODataEntity) targetHandler.getInternal()).
+ getNavigationLink(navPropName)).getAnnotations()
+ : ((ODataEntity) targetHandler.getInternal()).getProperty(propName).getAnnotations();
+ } else if (targetHandler.getInternal() instanceof ODataLinkedComplexValue) {
+ result = propName == null
+ ? ((org.apache.olingo.commons.api.domain.v4.ODataLink) ((ODataLinkedComplexValue) targetHandler.
+ getInternal()).getNavigationLink(navPropName)).getAnnotations()
+ : ((ODataLinkedComplexValue) targetHandler.getInternal()).get(propName).getAnnotations();
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void addAnnotation(final Class extends AbstractTerm> term, final Object value) {
+ this.annotations.put(term, value);
+
+ if (value != null) {
+ Collection> coll;
+ if (Collection.class.isAssignableFrom(value.getClass())) {
+ coll = Collection.class.cast(value);
+ } else {
+ coll = Collections.singleton(value);
+ }
+
+ for (Object item : coll) {
+ if (item instanceof Proxy) {
+ final InvocationHandler handler = Proxy.getInvocationHandler(item);
+ if ((handler instanceof ComplexInvocationHandler)
+ && ((ComplexInvocationHandler) handler).getEntityHandler() == null) {
+ ((ComplexInvocationHandler) handler).setEntityHandler(entityHandler);
+ }
+ }
+ }
+ }
+
+ entityHandler.attach(AttachedEntityStatus.CHANGED);
+ if (navPropName == null) {
+ targetHandler.putPropAnnotatableHandler(propName, this);
+ } else {
+ targetHandler.putNavPropAnnotatableHandler(navPropName, this);
+ }
+ }
+
+ @Override
+ public void removeAnnotation(final Class extends AbstractTerm> term) {
+ this.annotations.remove(term);
+
+ entityHandler.attach(AttachedEntityStatus.CHANGED);
+ if (navPropName == null) {
+ targetHandler.putPropAnnotatableHandler(propName, this);
+ } else {
+ targetHandler.putNavPropAnnotatableHandler(navPropName, this);
+ }
+ }
+
+ @Override
+ public Object getAnnotation(final Class extends AbstractTerm> term) {
+ Object res = null;
+
+ if (annotations.containsKey(term)) {
+ res = annotations.get(term);
+ } else if (entityHandler.getEntity() instanceof ODataEntity) {
+ try {
+ final Term termAnn = term.getAnnotation(Term.class);
+ final Namespace namespaceAnn = term.getAnnotation(Namespace.class);
+ ODataAnnotation annotation = null;
+ for (ODataAnnotation _annotation : internalAnnotations()) {
+ if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) {
+ annotation = _annotation;
+ }
+ }
+ res = annotation == null || annotation.hasNullValue()
+ ? null
+ : CoreUtils.getObjectFromODataValue(
+ client, annotation.getValue(), null, targetHandler.getEntityHandler());
+ if (res != null) {
+ annotations.put(term, res);
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Error getting annotation for term '" + term.getName() + "'", e);
+ }
+ }
+
+ return res;
+ }
+
+ @Override
+ public Collection> getAnnotationTerms() {
+ return entityHandler.getEntity() instanceof ODataEntity
+ ? CoreUtils.getAnnotationTerms(internalAnnotations())
+ : Collections.>emptyList();
+ }
+}
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java
new file mode 100644
index 000000000..d9ef3eaf5
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java
@@ -0,0 +1,91 @@
+/*
+ * 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 org.apache.olingo.client.api.CommonEdmEnabledODataClient;
+import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty;
+import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty;
+import org.apache.olingo.ext.proxy.utils.ClassUtils;
+
+public class AnnotatationsInvocationHandler extends AbstractInvocationHandler {
+
+ private static final long serialVersionUID = -1993362719908718985L;
+
+ private final EntityInvocationHandler entityHandler;
+
+ private final AbstractStructuredInvocationHandler targetHandler;
+
+ static AnnotatationsInvocationHandler getInstance(
+ final EntityInvocationHandler entityHandler,
+ final AbstractStructuredInvocationHandler targetHandler) {
+
+ return new AnnotatationsInvocationHandler(
+ entityHandler == null ? null : entityHandler.containerHandler.client,
+ targetHandler == null
+ ? entityHandler == null ? null : entityHandler.containerHandler : targetHandler.containerHandler,
+ entityHandler,
+ targetHandler);
+ }
+
+ private AnnotatationsInvocationHandler(
+ final CommonEdmEnabledODataClient> client,
+ final EntityContainerInvocationHandler containerHandler,
+ final EntityInvocationHandler entityHandler,
+ final AbstractStructuredInvocationHandler targetHandler) {
+
+ super(client, containerHandler);
+ this.targetHandler = targetHandler;
+ this.entityHandler = entityHandler;
+ }
+
+ @Override
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+ if (isSelfMethod(method, args)) {
+ return invokeSelfMethod(method, args);
+ } else if (method.getName().startsWith("get") && method.getName().endsWith("Annotations")) {
+ final Method getter = proxy.getClass().getInterfaces()[0].getMethod(method.getName());
+
+ String propName = null;
+ String navPropName = null;
+
+ final AnnotationsForProperty annForProp = ClassUtils.getAnnotation(AnnotationsForProperty.class, getter);
+ if (annForProp == null) {
+ final AnnotationsForNavigationProperty annForNavProp =
+ ClassUtils.getAnnotation(AnnotationsForNavigationProperty.class, getter);
+ if (annForNavProp == null) {
+ throw new UnsupportedOperationException("Unsupported method " + method.getName());
+ }
+
+ navPropName = annForNavProp.name();
+ } else {
+ propName = annForProp.name();
+ }
+
+ return Proxy.newProxyInstance(
+ Thread.currentThread().getContextClassLoader(),
+ new Class>[] {method.getReturnType()},
+ new AnnotatableInvocationHandler(
+ client, containerHandler, propName, navPropName, entityHandler, targetHandler));
+ } else {
+ throw new NoSuchMethodException(method.getName());
+ }
+ }
+}
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java
index 74ea4655b..2429a0279 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java
@@ -45,6 +45,7 @@ class ComplexFactoryInvocationHandler extends AbstractInvocationHandler implemen
static ComplexFactoryInvocationHandler getInstance(
final EntityInvocationHandler entityHandler,
final AbstractStructuredInvocationHandler targetHandler) {
+
return new ComplexFactoryInvocationHandler(
entityHandler == null ? null : entityHandler.containerHandler.client,
targetHandler == null
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
index e3743fe88..a207e68a8 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
@@ -131,13 +131,21 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
}
@Override
- @SuppressWarnings("unchecked")
protected void setPropertyValue(final Property property, final Object value) {
final FullQualifiedName fqn =
new FullQualifiedName(ClassUtils.getNamespace(typeRef), typeRef.getAnnotation(ComplexType.class).name());
final EdmElement edmProperty = client.getCachedEdm().getComplexType(fqn).getProperty(property.name());
+ final EdmTypeInfo type = new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression(
+ edmProperty.isCollection() ? "Collection(" + property.type() + ")" : property.type()).build();
+
+ setPropertyValue(property.name(), type, value);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void setPropertyValue(final String name, final EdmTypeInfo type, final Object value) {
+
final Object toBeAdded;
if (value == null) {
@@ -145,7 +153,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
} else if (Collection.class.isAssignableFrom(value.getClass())) {
toBeAdded = new ArrayList