From ca66d671313eabdc04c9afc2854c6ef28bfd3920 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Francesco=20Chicchiricc=C3=B2?= <--global>
Date: Sat, 17 May 2014 16:06:18 +0200
Subject: [PATCH] [OLINGO-260] contained tests
---
.../ext/proxy/api/annotations/EntitySet.java | 5 +-
.../api/annotations/NavigationProperty.java | 2 +
.../commons/AbstractInvocationHandler.java | 36 +++++---
... AbstractStructuredInvocationHandler.java} | 43 +++++----
.../ComplexFactoryInvocationHandler.java | 18 ++--
...ler.java => ComplexInvocationHandler.java} | 20 ++---
.../ext/proxy/commons/ContainerImpl.java | 84 +++++++++--------
.../EntityContainerInvocationHandler.java | 4 +-
...dler.java => EntityInvocationHandler.java} | 49 +++++-----
.../commons/EntitySetInvocationHandler.java | 88 +++++++++---------
.../commons/OperationInvocationHandler.java | 8 +-
.../commons/SingletonInvocationHandler.java | 12 +--
.../ext/proxy/context/AttachedEntity.java | 8 +-
.../ext/proxy/context/EntityContext.java | 28 +++---
.../ext/proxy/context/EntityLinkDesc.java | 20 ++---
.../olingo/ext/proxy/context/EntityUUID.java | 15 ++--
.../olingo/ext/proxy/utils/CoreUtils.java | 26 +++---
.../ext/pojogen/AbstractPOJOGenMojo.java | 29 ++++++
.../olingo/ext/pojogen/AbstractUtility.java | 39 +++++---
.../pojogen/NavPropertyContainsTarget.java | 16 ++--
.../src/main/resources/containedEntitySet.vm | 65 ++++++++++++++
.../src/main/resources/container.vm | 1 -
.../src/main/resources/entitySet.vm | 2 +-
.../src/main/resources/entityType.vm | 18 ++--
.../src/main/resources/entityTypeKey.vm | 2 +-
.../src/main/resources/v30/complexType.vm | 2 +-
.../src/main/resources/v30/entitySet.vm | 19 ----
.../src/main/resources/v40/complexType.vm | 4 +-
.../src/main/resources/v40/entitySet.vm | 19 ----
.../MyPaymentInstruments(101902).full.json | 16 ++++
.../links/MyPaymentInstruments(101902).xml | 40 +++++++++
.../fit/proxy/v3/ContextTestITCase.java | 90 +++++++++----------
.../proxy/v3/EntityRetrieveTestITCase.java | 4 +-
.../fit/proxy/v3/EntityUpdateTestITCase.java | 4 +-
.../fit/proxy/v4/DerivedTypeTestITCase.java | 13 ++-
.../fit/proxy/v4/EntityCreateTestITCase.java | 33 +++++++
.../proxy/v4/EntityRetrieveTestITCase.java | 14 ++-
.../fit/proxy/v4/EntityUpdateTestITCase.java | 20 ++++-
.../services/opentypesservicev4/Row.java | 2 +-
.../services/opentypesservicev4/RowIndex.java | 2 +-
.../services/odatawcfservice/Accounts.java | 4 +-
.../odatawcfservice/ActiveSubscriptions.java | 51 +++++++++++
.../services/odatawcfservice/Assets.java | 51 +++++++++++
.../odatawcfservice/BillingStatements.java | 51 +++++++++++
.../odata/services/odatawcfservice/Boss.java | 1 -
.../odata/services/odatawcfservice/Club.java | 51 +++++++++++
.../services/odatawcfservice/Company.java | 1 -
.../odatawcfservice/CreditRecords.java | 51 +++++++++++
.../services/odatawcfservice/Customers.java | 4 +-
.../odatawcfservice/DefaultStoredPI.java | 1 -
.../services/odatawcfservice/Departments.java | 4 +-
.../services/odatawcfservice/Employees.java | 4 +-
.../odatawcfservice/InMemoryEntities.java | 13 ---
.../services/odatawcfservice/LabourUnion.java | 1 -
.../services/odatawcfservice/MyGiftCard.java | 51 +++++++++++
.../odatawcfservice/MyPaymentInstruments.java | 53 +++++++++++
.../odatawcfservice/OrderDetails.java | 4 +-
.../services/odatawcfservice/Orders.java | 4 +-
.../services/odatawcfservice/People.java | 4 +-
.../odatawcfservice/ProductDetails.java | 4 +-
.../odatawcfservice/ProductReviews.java | 4 +-
.../services/odatawcfservice/Products.java | 4 +-
.../odatawcfservice/PublicCompany.java | 1 -
.../services/odatawcfservice/StoredPIs.java | 4 +-
.../SubscriptionTemplates.java | 4 +-
.../services/odatawcfservice/VipCustomer.java | 1 -
.../odatawcfservice/package-info.java | 1 -
.../odatawcfservice/types/AccessLevel.java | 1 -
.../odatawcfservice/types/Account.java | 43 +++++----
.../types/AccountCollection.java | 1 -
.../odatawcfservice/types/AccountInfo.java | 5 +-
.../odatawcfservice/types/Address.java | 7 +-
.../services/odatawcfservice/types/Asset.java | 7 +-
.../types/AssetCollection.java | 1 -
.../services/odatawcfservice/types/Club.java | 5 +-
.../odatawcfservice/types/ClubCollection.java | 1 -
.../services/odatawcfservice/types/Color.java | 1 -
.../odatawcfservice/types/Company.java | 43 +++++----
.../odatawcfservice/types/CompanyAddress.java | 9 +-
.../types/CompanyCategory.java | 1 -
.../types/CompanyCollection.java | 1 -
.../odatawcfservice/types/CreditCardPI.java | 53 ++++++-----
.../types/CreditCardPICollection.java | 1 -
.../odatawcfservice/types/CreditRecord.java | 9 +-
.../types/CreditRecordCollection.java | 1 -
.../odatawcfservice/types/Customer.java | 47 +++++-----
.../types/CustomerCollection.java | 1 -
.../odatawcfservice/types/Department.java | 15 ++--
.../types/DepartmentCollection.java | 1 -
.../odatawcfservice/types/Employee.java | 37 ++++----
.../types/EmployeeCollection.java | 1 -
.../odatawcfservice/types/GiftCard.java | 11 ++-
.../types/GiftCardCollection.java | 1 -
.../odatawcfservice/types/HomeAddress.java | 9 +-
.../odatawcfservice/types/LabourUnion.java | 5 +-
.../types/LabourUnionCollection.java | 1 -
.../services/odatawcfservice/types/Order.java | 33 ++++---
.../types/OrderCollection.java | 1 -
.../odatawcfservice/types/OrderDetail.java | 27 +++---
.../types/OrderDetailCollection.java | 1 -
.../odatawcfservice/types/OrderDetailKey.java | 5 +-
.../types/PaymentInstrument.java | 33 ++++---
.../types/PaymentInstrumentCollection.java | 1 -
.../odatawcfservice/types/Person.java | 25 +++---
.../types/PersonCollection.java | 1 -
.../odatawcfservice/types/Product.java | 27 +++---
.../types/ProductCollection.java | 1 -
.../odatawcfservice/types/ProductDetail.java | 25 +++---
.../types/ProductDetailCollection.java | 1 -
.../types/ProductDetailKey.java | 5 +-
.../odatawcfservice/types/ProductReview.java | 13 ++-
.../types/ProductReviewCollection.java | 1 -
.../types/ProductReviewKey.java | 9 +-
.../odatawcfservice/types/PublicCompany.java | 71 ++++++++-------
.../types/PublicCompanyCollection.java | 1 -
.../odatawcfservice/types/Statement.java | 9 +-
.../types/StatementCollection.java | 1 -
.../odatawcfservice/types/StoredPI.java | 9 +-
.../types/StoredPICollection.java | 1 -
.../odatawcfservice/types/Subscription.java | 11 ++-
.../types/SubscriptionCollection.java | 1 -
.../odatawcfservice/types/package-info.java | 1 -
.../apache/olingo/fit/v4/AsyncTestITCase.java | 2 +-
.../fit/v4/EntityRetrieveTestITCase.java | 4 +-
.../core/edm/primitivetype/EdmDuration.java | 1 -
125 files changed, 1239 insertions(+), 748 deletions(-)
rename ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/{AbstractTypeInvocationHandler.java => AbstractStructuredInvocationHandler.java} (87%)
rename ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/{ComplexTypeInvocationHandler.java => ComplexInvocationHandler.java} (90%)
rename ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/{EntityTypeInvocationHandler.java => EntityInvocationHandler.java} (89%)
create mode 100644 ext/pojogen-maven-plugin/src/main/resources/containedEntitySet.vm
delete mode 100644 ext/pojogen-maven-plugin/src/main/resources/v30/entitySet.vm
delete mode 100644 ext/pojogen-maven-plugin/src/main/resources/v40/entitySet.vm
create mode 100644 fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101902).full.json
create mode 100644 fit/src/main/resources/V40/Accounts/101/links/MyPaymentInstruments(101902).xml
create mode 100644 fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/ActiveSubscriptions.java
create mode 100644 fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Assets.java
create mode 100644 fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/BillingStatements.java
create mode 100644 fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Club.java
create mode 100644 fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/CreditRecords.java
create mode 100644 fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/MyGiftCard.java
create mode 100644 fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/MyPaymentInstruments.java
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntitySet.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntitySet.java
index 0a94df45d..8da4baa74 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntitySet.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/EntitySet.java
@@ -25,8 +25,7 @@ import java.lang.annotation.Target;
/**
* Give entity set a name. If interface extending EntitySet is not annotated with this, the effective name will be
- * class'
- * getSimpleName().
+ * class'getSimpleName().
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@@ -34,5 +33,5 @@ public @interface EntitySet {
String name();
- boolean includeInServiceDocument() default true;
+ boolean contained() default false;
}
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/NavigationProperty.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/NavigationProperty.java
index 88379bc63..fd51b04df 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/NavigationProperty.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/NavigationProperty.java
@@ -39,4 +39,6 @@ public @interface NavigationProperty {
String targetContainer();
String targetEntitySet();
+
+ boolean containsTarget() default false;
}
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 5181b48fa..e3a2bc9ef 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
@@ -87,7 +87,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
}
@SuppressWarnings({"unchecked", "rawtypes"})
- protected Object getEntityCollection(
+ protected Object getEntityCollectionProxy(
final Class> typeRef,
final Class> typeCollectionRef,
final String entityContainerName,
@@ -99,7 +99,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
for (CommonODataEntity entityFromSet : entitySet.getEntities()) {
items.add(getEntityProxy(
- entityFromSet, entityContainerName, null, typeRef, checkInTheContext));
+ entityFromSet.getEditLink(), entityFromSet, entityContainerName, null, typeRef, checkInTheContext));
}
return Proxy.newProxyInstance(
@@ -108,27 +108,38 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
new EntityCollectionInvocationHandler(containerHandler, items, typeRef, uri));
}
- protected T getEntityProxy(
+ protected Object getEntitySetProxy(
+ final Class> typeRef,
+ final URI uri) {
+
+ return Proxy.newProxyInstance(
+ Thread.currentThread().getContextClassLoader(),
+ new Class>[] {typeRef},
+ EntitySetInvocationHandler.getInstance(typeRef, containerHandler, uri));
+ }
+
+ protected Object getEntityProxy(
+ final URI entityURI,
final CommonODataEntity entity,
final String entityContainerName,
- final String entitySetName,
+ final URI entitySetURI,
final Class> type,
final boolean checkInTheContext) {
- return getEntityProxy(entity, entityContainerName, entitySetName, type, null, checkInTheContext);
+ return getEntityProxy(entityURI, entity, entityContainerName, entitySetURI, type, null, checkInTheContext);
}
- @SuppressWarnings({"unchecked"})
- protected T getEntityProxy(
+ protected Object getEntityProxy(
+ final URI entityURI,
final CommonODataEntity entity,
final String entityContainerName,
- final String entitySetName,
+ final URI entitySetURI,
final Class> type,
final String eTag,
final boolean checkInTheContext) {
- EntityTypeInvocationHandler handler =
- EntityTypeInvocationHandler.getInstance(entity, entitySetName, type, containerHandler);
+ EntityInvocationHandler handler =
+ EntityInvocationHandler.getInstance(entityURI, entity, entitySetURI, type, containerHandler);
if (StringUtils.isNotBlank(eTag)) {
// override ETag into the wrapped object.
@@ -139,7 +150,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
handler = EntityContainerFactory.getContext().entityContext().getEntity(handler.getUUID());
}
- return (T) Proxy.newProxyInstance(
+ return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class>[] {type},
handler);
@@ -196,7 +207,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
if (edmType.isCollection()) {
final ParameterizedType collType = (ParameterizedType) method.getReturnType().getGenericInterfaces()[0];
final Class> collItemType = (Class>) collType.getActualTypeArguments()[0];
- return getEntityCollection(
+ return getEntityCollectionProxy(
collItemType,
method.getReturnType(),
null,
@@ -205,6 +216,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
false);
} else {
return getEntityProxy(
+ ((CommonODataEntity) result).getEditLink(),
(CommonODataEntity) result,
null,
null,
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractTypeInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
similarity index 87%
rename from ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractTypeInvocationHandler.java
rename to ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
index 169ddfeae..2e6103e79 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractTypeInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java
@@ -37,6 +37,7 @@ import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataLinked;
import org.apache.olingo.ext.proxy.EntityContainerFactory;
import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
+import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
import org.apache.olingo.ext.proxy.api.annotations.EntityType;
import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty;
import org.apache.olingo.ext.proxy.api.annotations.Property;
@@ -46,24 +47,24 @@ import org.apache.olingo.ext.proxy.utils.ClassUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHandler {
+public abstract class AbstractStructuredInvocationHandler extends AbstractInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
/**
* Logger.
*/
- protected static final Logger LOG = LoggerFactory.getLogger(AbstractTypeInvocationHandler.class);
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractStructuredInvocationHandler.class);
protected final Class> typeRef;
protected final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
- protected EntityTypeInvocationHandler entityHandler;
+ protected EntityInvocationHandler entityHandler;
protected Object internal;
- protected AbstractTypeInvocationHandler(
+ protected AbstractStructuredInvocationHandler(
final CommonEdmEnabledODataClient> client,
final Class> typeRef,
final Object internal,
@@ -72,14 +73,14 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
super(client, containerHandler);
this.internal = internal;
this.typeRef = typeRef;
- this.entityHandler = EntityTypeInvocationHandler.class.cast(this);
+ this.entityHandler = EntityInvocationHandler.class.cast(this);
}
- protected AbstractTypeInvocationHandler(
+ protected AbstractStructuredInvocationHandler(
final CommonEdmEnabledODataClient> client,
final Class> typeRef,
final Object internal,
- final EntityTypeInvocationHandler entityHandler) {
+ final EntityInvocationHandler entityHandler) {
super(client, entityHandler == null ? null : entityHandler.containerHandler);
this.internal = internal;
@@ -87,11 +88,11 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
this.entityHandler = entityHandler;
}
- public EntityTypeInvocationHandler getEntityHandler() {
+ public EntityInvocationHandler getEntityHandler() {
return entityHandler;
}
- public void setEntityHandler(EntityTypeInvocationHandler entityHandler) {
+ public void setEntityHandler(EntityInvocationHandler entityHandler) {
this.entityHandler = entityHandler;
}
@@ -191,7 +192,9 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
protected abstract Object getNavigationPropertyValue(final NavigationProperty property, final Method getter);
- protected Object retriveNavigationProperty(final NavigationProperty property, final Method getter) {
+ protected Object retrieveNavigationProperty(
+ final NavigationProperty property, final Method getter, final String serviceRoot) {
+
final Class> type = getter.getReturnType();
final Class> collItemType;
if (AbstractEntityCollection.class.isAssignableFrom(type)) {
@@ -208,14 +211,15 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
if (link instanceof ODataInlineEntity) {
// return entity
navPropValue = getEntityProxy(
+ null,
((ODataInlineEntity) link).getEntity(),
property.targetContainer(),
- property.targetEntitySet(),
+ client.getURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(),
type,
false);
} else if (link instanceof ODataInlineEntitySet) {
// return entity set
- navPropValue = getEntityCollection(
+ navPropValue = getEntityCollectionProxy(
collItemType,
type,
property.targetContainer(),
@@ -224,25 +228,26 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
false);
} else {
// navigate
- final URI uri = URIUtils.getURI(
- containerHandler.getFactory().getServiceRoot(), link.getLink().toASCIIString());
-
+ final URI uri = URIUtils.getURI(containerHandler.getFactory().getServiceRoot(), link.getLink().toASCIIString());
if (AbstractEntityCollection.class.isAssignableFrom(type)) {
- navPropValue = getEntityCollection(
+ navPropValue = getEntityCollectionProxy(
collItemType,
type,
property.targetContainer(),
client.getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody(),
uri,
true);
+ } else if (AbstractEntitySet.class.isAssignableFrom(type)) {
+ navPropValue = getEntitySetProxy(type, uri);
} else {
final ODataRetrieveResponse res =
client.getRetrieveRequestFactory().getEntityRequest(uri).execute();
navPropValue = getEntityProxy(
+ uri,
res.getBody(),
property.targetContainer(),
- property.targetEntitySet(),
+ client.getURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(),
type,
res.getETag(),
true);
@@ -280,11 +285,11 @@ public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHa
? (AbstractEntityCollection) value : Collections.singleton(value)) {
final InvocationHandler etih = Proxy.getInvocationHandler(link);
- if (!(etih instanceof EntityTypeInvocationHandler)) {
+ if (!(etih instanceof EntityInvocationHandler)) {
throw new IllegalArgumentException("Invalid argument type");
}
- final EntityTypeInvocationHandler linkedHandler = (EntityTypeInvocationHandler) etih;
+ final EntityInvocationHandler linkedHandler = (EntityInvocationHandler) etih;
if (!linkedHandler.getTypeRef().isAnnotationPresent(EntityType.class)) {
throw new IllegalArgumentException("Invalid argument type " + linkedHandler.getTypeRef().getSimpleName());
}
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 2f833c6d6..74ea4655b 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
@@ -29,22 +29,22 @@ class ComplexFactoryInvocationHandler extends AbstractInvocationHandler implemen
private static final long serialVersionUID = 2629912294765040027L;
- private final EntityTypeInvocationHandler entityHandler;
+ private final EntityInvocationHandler entityHandler;
- private final AbstractTypeInvocationHandler invokerHandler;
+ private final AbstractStructuredInvocationHandler invokerHandler;
static ComplexFactoryInvocationHandler getInstance(
final CommonEdmEnabledODataClient> client,
final EntityContainerInvocationHandler containerHandler,
- final EntityTypeInvocationHandler entityHandler,
- final AbstractTypeInvocationHandler targetHandler) {
+ final EntityInvocationHandler entityHandler,
+ final AbstractStructuredInvocationHandler targetHandler) {
return new ComplexFactoryInvocationHandler(client, containerHandler, entityHandler, targetHandler);
}
static ComplexFactoryInvocationHandler getInstance(
- final EntityTypeInvocationHandler entityHandler,
- final AbstractTypeInvocationHandler targetHandler) {
+ final EntityInvocationHandler entityHandler,
+ final AbstractStructuredInvocationHandler targetHandler) {
return new ComplexFactoryInvocationHandler(
entityHandler == null ? null : entityHandler.containerHandler.client,
targetHandler == null
@@ -56,8 +56,8 @@ class ComplexFactoryInvocationHandler extends AbstractInvocationHandler implemen
private ComplexFactoryInvocationHandler(
final CommonEdmEnabledODataClient> client,
final EntityContainerInvocationHandler containerHandler,
- final EntityTypeInvocationHandler entityHandler,
- final AbstractTypeInvocationHandler targetHandler) {
+ final EntityInvocationHandler entityHandler,
+ final AbstractStructuredInvocationHandler targetHandler) {
super(client, containerHandler);
this.invokerHandler = targetHandler;
@@ -78,7 +78,7 @@ class ComplexFactoryInvocationHandler extends AbstractInvocationHandler implemen
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class>[] {method.getReturnType()},
- ComplexTypeInvocationHandler.getInstance(client, property.name(), method.getReturnType(), entityHandler));
+ ComplexInvocationHandler.getInstance(client, property.name(), method.getReturnType(), entityHandler));
} else {
throw new NoSuchMethodException(method.getName());
}
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexTypeInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
similarity index 90%
rename from ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexTypeInvocationHandler.java
rename to ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
index 2175e8cd5..72d42e801 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexTypeInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java
@@ -41,15 +41,15 @@ import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
import org.apache.olingo.ext.proxy.utils.ClassUtils;
import org.apache.olingo.ext.proxy.utils.CoreUtils;
-public class ComplexTypeInvocationHandler extends AbstractTypeInvocationHandler {
+public class ComplexInvocationHandler extends AbstractStructuredInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
- public static ComplexTypeInvocationHandler getInstance(
+ public static ComplexInvocationHandler getInstance(
final CommonEdmEnabledODataClient> client,
final String propertyName,
final Class> reference,
- final EntityTypeInvocationHandler handler) {
+ final EntityInvocationHandler handler) {
final Class> complexTypeRef;
if (Collection.class.isAssignableFrom(reference)) {
@@ -69,24 +69,24 @@ public class ComplexTypeInvocationHandler extends AbstractTypeInvocationHandler
final ODataComplexValue extends CommonODataProperty> complex =
client.getObjectFactory().newComplexValue(typeName.toString());
- return (ComplexTypeInvocationHandler) ComplexTypeInvocationHandler.getInstance(
+ return (ComplexInvocationHandler) ComplexInvocationHandler.getInstance(
client, complex, complexTypeRef, handler);
}
- public static ComplexTypeInvocationHandler getInstance(
+ public static ComplexInvocationHandler getInstance(
final CommonEdmEnabledODataClient> client,
final ODataComplexValue> complex,
final Class> typeRef,
- final EntityTypeInvocationHandler handler) {
+ final EntityInvocationHandler handler) {
- return new ComplexTypeInvocationHandler(client, complex, typeRef, handler);
+ return new ComplexInvocationHandler(client, complex, typeRef, handler);
}
- public ComplexTypeInvocationHandler(
+ public ComplexInvocationHandler(
final CommonEdmEnabledODataClient> client,
final ODataComplexValue> complex,
final Class> typeRef,
- final EntityTypeInvocationHandler handler) {
+ final EntityInvocationHandler handler) {
super(client, typeRef, complex, handler);
}
@@ -166,7 +166,7 @@ public class ComplexTypeInvocationHandler extends AbstractTypeInvocationHandler
throw new UnsupportedOperationException("Internal object is not navigable");
}
- return retriveNavigationProperty(property, getter);
+ return retrieveNavigationProperty(property, getter, containerHandler.getFactory().getServiceRoot());
}
@Override
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
index ab824ecf3..90a4d756d 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
@@ -46,7 +46,6 @@ import org.apache.olingo.client.api.communication.response.ODataBatchResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataResponse;
-import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
@@ -75,9 +74,9 @@ class ContainerImpl implements Container {
private final CommonEdmEnabledODataClient> client;
- private final EntityContainerFactory factory;
+ private final EntityContainerFactory> factory;
- ContainerImpl(final CommonEdmEnabledODataClient> client, final EntityContainerFactory factory) {
+ ContainerImpl(final CommonEdmEnabledODataClient> client, final EntityContainerFactory> factory) {
this.client = client;
this.factory = factory;
}
@@ -88,7 +87,7 @@ class ContainerImpl implements Container {
@Override
public void flush() {
final CommonODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(client.getServiceRoot());
- ((ODataRequest)request).setAccept(client.getConfiguration().getDefaultBatchAcceptFormat());
+ ((ODataRequest) request).setAccept(client.getConfiguration().getDefaultBatchAcceptFormat());
final BatchStreamManager streamManager = (BatchStreamManager) ((ODataStreamedRequest) request).execute();
@@ -138,13 +137,13 @@ class ContainerImpl implements Container {
throw new IllegalStateException("Transaction failed: " + res.getStatusMessage());
}
- final EntityTypeInvocationHandler handler = items.get(changesetItemId);
+ final EntityInvocationHandler handler = items.get(changesetItemId);
if (handler != null) {
- if (res instanceof ODataEntityCreateResponse) {
+ if (res instanceof ODataEntityCreateResponse && res.getStatusCode() == 201) {
handler.setEntity(((ODataEntityCreateResponse) res).getBody());
LOG.debug("Upgrade created object '{}'", handler);
- } else if (res instanceof ODataEntityUpdateResponse) {
+ } else if (res instanceof ODataEntityUpdateResponse && res.getStatusCode() == 200) {
handler.setEntity(((ODataEntityUpdateResponse) res).getBody());
LOG.debug("Upgrade updated object '{}'", handler);
}
@@ -156,7 +155,7 @@ class ContainerImpl implements Container {
}
private void batch(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final CommonODataEntity entity,
final ODataChangeset changeset) {
@@ -181,19 +180,17 @@ class ContainerImpl implements Container {
}
private void batchCreate(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final CommonODataEntity entity,
final ODataChangeset changeset) {
LOG.debug("Create '{}'", handler);
- final CommonURIBuilder> uriBuilder = client.getURIBuilder(factory.getServiceRoot()).
- appendEntitySetSegment(handler.getEntitySetName());
- changeset.addRequest(client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), entity));
+ changeset.addRequest(client.getCUDRequestFactory().getEntityCreateRequest(handler.getEntitySetURI(), entity));
}
private void batchUpdateMediaEntity(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final URI uri,
final InputStream input,
final ODataChangeset changeset) {
@@ -215,7 +212,7 @@ class ContainerImpl implements Container {
}
private void batchUpdateMediaResource(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final URI uri,
final InputStream input,
final ODataChangeset changeset) {
@@ -232,18 +229,20 @@ class ContainerImpl implements Container {
}
private void batchUpdate(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final CommonODataEntity changes,
final ODataChangeset changeset) {
- LOG.debug("Update '{}'", changes.getEditLink());
+ LOG.debug("Update '{}'", handler.getEntityURI());
final ODataEntityUpdateRequest req =
client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) client).getCUDRequestFactory().
- getEntityUpdateRequest(org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
+ getEntityUpdateRequest(handler.getEntityURI(),
+ org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
: ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) client).getCUDRequestFactory().
- getEntityUpdateRequest(org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
+ getEntityUpdateRequest(handler.getEntityURI(),
+ org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
req.setPrefer(new ODataPreferences(client.getServiceVersion()).returnContent());
@@ -255,7 +254,7 @@ class ContainerImpl implements Container {
}
private void batchUpdate(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final URI uri,
final CommonODataEntity changes,
final ODataChangeset changeset) {
@@ -265,11 +264,11 @@ class ContainerImpl implements Container {
final ODataEntityUpdateRequest req =
client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) client).getCUDRequestFactory().
- getEntityUpdateRequest(
- uri, org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
+ getEntityUpdateRequest(uri,
+ org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes)
: ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) client).getCUDRequestFactory().
- getEntityUpdateRequest(
- uri, org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
+ getEntityUpdateRequest(uri,
+ org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes);
req.setPrefer(new ODataPreferences(client.getServiceVersion()).returnContent());
@@ -281,14 +280,14 @@ class ContainerImpl implements Container {
}
private void batchDelete(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
final CommonODataEntity entity,
final ODataChangeset changeset) {
- LOG.debug("Delete '{}'", entity.getEditLink());
+ final URI deleteURI = handler.getEntityURI() == null ? entity.getEditLink() : handler.getEntityURI();
+ LOG.debug("Delete '{}'", deleteURI);
- final ODataDeleteRequest req = client.getCUDRequestFactory().getDeleteRequest(URIUtils.getURI(
- factory.getServiceRoot(), entity.getEditLink().toASCIIString()));
+ final ODataDeleteRequest req = client.getCUDRequestFactory().getDeleteRequest(deleteURI);
if (StringUtils.isNotBlank(handler.getETag())) {
req.setIfMatch(handler.getETag());
@@ -298,7 +297,7 @@ class ContainerImpl implements Container {
}
private int processEntityContext(
- final EntityTypeInvocationHandler handler,
+ final EntityInvocationHandler handler,
int pos,
final TransactionItems items,
final List delayedUpdates,
@@ -323,14 +322,14 @@ class ContainerImpl implements Container {
? ODataLinkType.ENTITY_SET_NAVIGATION
: ODataLinkType.ENTITY_NAVIGATION;
- final Set toBeLinked = new HashSet();
+ final Set toBeLinked = new HashSet();
final String serviceRoot = factory.getServiceRoot();
for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
? (Collection) property.getValue() : Collections.singleton(property.getValue())) {
- final EntityTypeInvocationHandler target =
- (EntityTypeInvocationHandler) Proxy.getInvocationHandler(proxy);
+ final EntityInvocationHandler target =
+ (EntityInvocationHandler) Proxy.getInvocationHandler(proxy);
final AttachedEntityStatus status =
EntityContainerFactory.getContext().entityContext().getStatus(target);
@@ -360,8 +359,7 @@ class ContainerImpl implements Container {
// create the link for the current object
LOG.debug("'{}' from '{}' to (${}) '{}'", type.name(), handler, targetPos, target);
- entity.addLink(
- buildNavigationLink(property.getKey().name(), URI.create("$" + targetPos), type));
+ entity.addLink(buildNavigationLink(property.getKey().name(), URI.create("$" + targetPos), type));
}
}
}
@@ -396,7 +394,7 @@ class ContainerImpl implements Container {
final URI targetURI = currentStatus == AttachedEntityStatus.NEW
? URI.create("$" + startingPos + "/$value")
: URIUtils.getURI(
- factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString() + "/$value");
+ factory.getServiceRoot(), handler.getEntity().getEditLink().toASCIIString() + "/$value");
batchUpdateMediaEntity(handler, targetURI, handler.getStreamChanges(), changeset);
@@ -409,8 +407,8 @@ class ContainerImpl implements Container {
for (Map.Entry streamedChanges : handler.getStreamedPropertyChanges().entrySet()) {
final URI targetURI = currentStatus == AttachedEntityStatus.NEW
? URI.create("$" + startingPos) : URIUtils.getURI(
- factory.getServiceRoot(),
- CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString());
+ factory.getServiceRoot(),
+ CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString());
batchUpdateMediaResource(handler, targetURI, streamedChanges.getValue(), changeset);
@@ -467,7 +465,7 @@ class ContainerImpl implements Container {
sourceURI = URI.create("$" + sourcePos);
}
- for (EntityTypeInvocationHandler target : delayedUpdate.getTargets()) {
+ for (EntityInvocationHandler target : delayedUpdate.getTargets()) {
status = EntityContainerFactory.getContext().entityContext().getStatus(target);
final URI targetURI;
@@ -492,11 +490,11 @@ class ContainerImpl implements Container {
private class TransactionItems {
- private final List keys = new ArrayList();
+ private final List keys = new ArrayList();
private final List values = new ArrayList();
- public EntityTypeInvocationHandler get(final Integer value) {
+ public EntityInvocationHandler get(final Integer value) {
if (value != null && values.contains(value)) {
return keys.get(values.indexOf(value));
} else {
@@ -504,7 +502,7 @@ class ContainerImpl implements Container {
}
}
- public Integer get(final EntityTypeInvocationHandler key) {
+ public Integer get(final EntityInvocationHandler key) {
if (key != null && keys.contains(key)) {
return values.get(keys.indexOf(key));
} else {
@@ -512,14 +510,14 @@ class ContainerImpl implements Container {
}
}
- public void remove(final EntityTypeInvocationHandler key) {
+ public void remove(final EntityInvocationHandler key) {
if (keys.contains(key)) {
values.remove(keys.indexOf(key));
keys.remove(key);
}
}
- public void put(final EntityTypeInvocationHandler key, final Integer value) {
+ public void put(final EntityInvocationHandler key, final Integer value) {
// replace just in case of null current value; otherwise add the new entry
if (key != null && keys.contains(key) && values.get(keys.indexOf(key)) == null) {
remove(key);
@@ -534,7 +532,7 @@ class ContainerImpl implements Container {
return sortedValues;
}
- public boolean contains(final EntityTypeInvocationHandler key) {
+ public boolean contains(final EntityInvocationHandler key) {
return keys.contains(key);
}
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 299a84262..17f2f5ce4 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
@@ -113,13 +113,13 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class>[] {returnType},
- SingletonInvocationHandler.getInstance(returnType, this));
+ SingletonInvocationHandler.getInstance(returnType, this, singleton.name()));
}
} else {
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class>[] {returnType},
- EntitySetInvocationHandler.getInstance(returnType, this));
+ EntitySetInvocationHandler.getInstance(returnType, this, entitySet.name()));
}
throw new NoSuchMethodException(method.getName());
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityTypeInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
similarity index 89%
rename from ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityTypeInvocationHandler.java
rename to ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
index 57b73d0cc..361c14031 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityTypeInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java
@@ -47,10 +47,12 @@ import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
import org.apache.olingo.ext.proxy.context.EntityUUID;
import org.apache.olingo.ext.proxy.utils.CoreUtils;
-public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
+public class EntityInvocationHandler extends AbstractStructuredInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
+ private final URI entityURI;
+
protected Map propertyChanges = new HashMap();
protected Map linkChanges = new HashMap();
@@ -65,41 +67,46 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
private EntityUUID uuid;
- static EntityTypeInvocationHandler getInstance(
+ static EntityInvocationHandler getInstance(
+ final URI entityURI,
final CommonODataEntity entity,
final EntitySetInvocationHandler, ?, ?> entitySet,
final Class> typeRef) {
return getInstance(
+ entityURI,
entity,
- entitySet.getEntitySetName(),
+ entitySet.getEntitySetURI(),
typeRef,
entitySet.containerHandler);
}
- static EntityTypeInvocationHandler getInstance(
+ static EntityInvocationHandler getInstance(
+ final URI entityURI,
final CommonODataEntity entity,
- final String entitySetName,
+ final URI entitySetURI,
final Class> typeRef,
final EntityContainerInvocationHandler containerHandler) {
- return new EntityTypeInvocationHandler(entity, entitySetName, typeRef, containerHandler);
+ return new EntityInvocationHandler(entityURI, entity, entitySetURI, typeRef, containerHandler);
}
- private EntityTypeInvocationHandler(
+ private EntityInvocationHandler(
+ final URI entityURI,
final CommonODataEntity entity,
- final String entitySetName,
+ final URI entitySetURI,
final Class> typeRef,
final EntityContainerInvocationHandler containerHandler) {
super(containerHandler.getClient(), typeRef, (ODataLinked) entity, containerHandler);
+ this.entityURI = entityURI;
this.internal = entity;
getEntity().setMediaEntity(typeRef.getAnnotation(EntityType.class).hasStream());
this.uuid = new EntityUUID(
containerHandler.getEntityContainerName(),
- entitySetName,
+ entitySetURI,
typeRef,
CoreUtils.getKey(client, typeRef, entity));
}
@@ -110,7 +117,7 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
this.uuid = new EntityUUID(
getUUID().getContainerName(),
- getUUID().getEntitySetName(),
+ getUUID().getEntitySetURI(),
getUUID().getType(),
CoreUtils.getKey(client, typeRef, entity));
@@ -129,14 +136,18 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
return uuid.getContainerName();
}
- public String getEntitySetName() {
- return uuid.getEntitySetName();
+ public URI getEntitySetURI() {
+ return uuid.getEntitySetURI();
}
public final CommonODataEntity getEntity() {
return (CommonODataEntity) internal;
}
+ public URI getEntityURI() {
+ return entityURI;
+ }
+
/**
* Gets the current ETag defined into the wrapped entity.
*
@@ -240,9 +251,9 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
for (Object item : coll) {
if (item instanceof Proxy) {
final InvocationHandler handler = Proxy.getInvocationHandler(item);
- if ((handler instanceof ComplexTypeInvocationHandler)
- && ((ComplexTypeInvocationHandler) handler).getEntityHandler() == null) {
- ((ComplexTypeInvocationHandler) handler).setEntityHandler(this);
+ if ((handler instanceof ComplexInvocationHandler)
+ && ((ComplexInvocationHandler) handler).getEntityHandler() == null) {
+ ((ComplexInvocationHandler) handler).setEntityHandler(this);
}
}
}
@@ -277,7 +288,6 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
}
public InputStream getStream() {
-
final URI contentSource = getEntity().getMediaContentSource();
if (this.stream == null
@@ -297,7 +307,6 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
}
public Object getStreamedProperty(final Property property) {
-
InputStream res = streamedPropertyChanges.get(property.name());
try {
@@ -334,7 +343,7 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
if (linkChanges.containsKey(property)) {
navPropValue = linkChanges.get(property);
} else {
- navPropValue = retriveNavigationProperty(property, getter);
+ navPropValue = retrieveNavigationProperty(property, getter, containerHandler.getFactory().getServiceRoot());
}
if (navPropValue != null) {
@@ -370,7 +379,7 @@ public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
@Override
public boolean equals(final Object obj) {
- return obj instanceof EntityTypeInvocationHandler
- && ((EntityTypeInvocationHandler) obj).getUUID().equals(uuid);
+ return obj instanceof EntityInvocationHandler
+ && ((EntityInvocationHandler) obj).getUUID().equals(uuid);
}
}
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 18c2ce29a..6e70a0e9f 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
@@ -73,8 +73,6 @@ class EntitySetInvocationHandler<
*/
private static final Logger LOG = LoggerFactory.getLogger(EntitySetInvocationHandler.class);
- private final String entitySetName;
-
private final boolean isSingleton;
private final Class typeRef;
@@ -85,28 +83,10 @@ class EntitySetInvocationHandler<
@SuppressWarnings({"rawtypes", "unchecked"})
static EntitySetInvocationHandler getInstance(
- final Class> ref, final EntityContainerInvocationHandler containerHandler) {
+ final Class> ref, final EntityContainerInvocationHandler containerHandler, final String entitySetName) {
- return new EntitySetInvocationHandler(ref, containerHandler, (ref.getAnnotation(EntitySet.class)).name());
- }
-
- @SuppressWarnings("unchecked")
- protected EntitySetInvocationHandler(
- final Class> ref,
- final EntityContainerInvocationHandler containerHandler,
- final String entitySetName) {
-
- super(containerHandler.getClient(), containerHandler);
-
- this.entitySetName = entitySetName;
- this.isSingleton = AbstractSingleton.class.isAssignableFrom(ref);
-
- final Type[] entitySetParams = ((ParameterizedType) ref.getGenericInterfaces()[0]).getActualTypeArguments();
-
- this.typeRef = (Class) entitySetParams[0];
- this.collTypeRef = (Class) entitySetParams[2];
-
- final CommonURIBuilder> uriBuilder = client.getURIBuilder(containerHandler.getFactory().getServiceRoot());
+ final CommonURIBuilder> uriBuilder = containerHandler.getClient().
+ getURIBuilder(containerHandler.getFactory().getServiceRoot());
final StringBuilder entitySetSegment = new StringBuilder();
if (!containerHandler.isDefaultEntityContainer()) {
@@ -115,7 +95,34 @@ class EntitySetInvocationHandler<
entitySetSegment.append(entitySetName);
uriBuilder.appendEntitySetSegment(entitySetSegment.toString());
- this.uri = uriBuilder.build();
+
+ return new EntitySetInvocationHandler(ref, containerHandler, entitySetName, uriBuilder.build());
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ static EntitySetInvocationHandler getInstance(
+ final Class> ref, final EntityContainerInvocationHandler containerHandler, final URI uri) {
+
+ return new EntitySetInvocationHandler(ref, containerHandler, (ref.getAnnotation(EntitySet.class)).name(), uri);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected EntitySetInvocationHandler(
+ final Class> ref,
+ final EntityContainerInvocationHandler containerHandler,
+ final String entitySetName,
+ final URI uri) {
+
+ super(containerHandler.getClient(), containerHandler);
+
+ this.isSingleton = AbstractSingleton.class.isAssignableFrom(ref);
+
+ final Type[] entitySetParams = ((ParameterizedType) ref.getGenericInterfaces()[0]).getActualTypeArguments();
+
+ this.typeRef = (Class) entitySetParams[0];
+ this.collTypeRef = (Class) entitySetParams[2];
+
+ this.uri = uri;
}
protected Class getTypeRef() {
@@ -126,11 +133,7 @@ class EntitySetInvocationHandler<
return collTypeRef;
}
- protected String getEntitySetName() {
- return entitySetName;
- }
-
- protected URI getURI() {
+ protected URI getEntitySetURI() {
return uri;
}
@@ -155,8 +158,8 @@ class EntitySetInvocationHandler<
final CommonODataEntity entity = client.getObjectFactory().newEntity(
new FullQualifiedName(containerHandler.getSchemaName(), ClassUtils.getEntityTypeName(reference)));
- final EntityTypeInvocationHandler handler =
- EntityTypeInvocationHandler.getInstance(entity, entitySetName, reference, containerHandler);
+ final EntityInvocationHandler handler =
+ EntityInvocationHandler.getInstance(null, entity, uri, reference, containerHandler);
EntityContainerFactory.getContext().entityContext().attachNew(handler);
return (NE) Proxy.newProxyInstance(
@@ -188,7 +191,7 @@ class EntitySetInvocationHandler<
try {
result = get(key) != null;
} catch (Exception e) {
- LOG.error("Could not check existence of {}({})", this.entitySetName, key, e);
+ LOG.error("Could not check existence of {}({})", this.uri, key, e);
}
return result;
@@ -230,10 +233,10 @@ class EntitySetInvocationHandler<
throw new IllegalArgumentException("Null key");
}
- final EntityUUID uuid = new EntityUUID(containerHandler.getEntityContainerName(), entitySetName, typeRef, key);
+ final EntityUUID uuid = new EntityUUID(containerHandler.getEntityContainerName(), uri, typeRef, key);
LOG.debug("Ask for '{}({})'", typeRef.getSimpleName(), key);
- EntityTypeInvocationHandler handler = EntityContainerFactory.getContext().entityContext().getEntity(uuid);
+ EntityInvocationHandler handler = EntityContainerFactory.getContext().entityContext().getEntity(uuid);
if (handler == null) {
// not yet attached: search against the service
@@ -261,7 +264,7 @@ class EntitySetInvocationHandler<
throw new IllegalArgumentException("Invalid " + typeRef.getSimpleName() + "(" + key + ")");
}
- handler = EntityTypeInvocationHandler.getInstance(entity, this, typeRef);
+ handler = EntityInvocationHandler.getInstance(uriBuilder.build(), entity, this, typeRef);
handler.setETag(etag);
} catch (Exception e) {
LOG.info("Entity '" + uuid + "' not found", e);
@@ -301,9 +304,10 @@ class EntitySetInvocationHandler<
final List items = new ArrayList(entities.size());
for (CommonODataEntity entity : entities) {
- final EntityTypeInvocationHandler handler = EntityTypeInvocationHandler.getInstance(entity, this, typeRef);
+ final EntityInvocationHandler handler =
+ EntityInvocationHandler.getInstance(entity.getEditLink(), entity, this, typeRef);
- final EntityTypeInvocationHandler handlerInTheContext =
+ final EntityInvocationHandler handlerInTheContext =
EntityContainerFactory.getContext().entityContext().getEntity(handler.getUUID());
items.add((S) Proxy.newProxyInstance(
@@ -396,16 +400,16 @@ class EntitySetInvocationHandler<
public void delete(final KEY key) throws IllegalArgumentException {
final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
- EntityTypeInvocationHandler entity = entityContext.getEntity(new EntityUUID(
+ EntityInvocationHandler entity = entityContext.getEntity(new EntityUUID(
containerHandler.getEntityContainerName(),
- entitySetName,
+ uri,
typeRef,
key));
if (entity == null) {
// search for entity
final T searched = get(key);
- entity = (EntityTypeInvocationHandler) Proxy.getInvocationHandler(searched);
+ entity = (EntityInvocationHandler) Proxy.getInvocationHandler(searched);
entityContext.attach(entity, AttachedEntityStatus.DELETED);
} else {
entityContext.setStatus(entity, AttachedEntityStatus.DELETED);
@@ -417,7 +421,7 @@ class EntitySetInvocationHandler<
final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
for (T en : entities) {
- final EntityTypeInvocationHandler entity = (EntityTypeInvocationHandler) Proxy.getInvocationHandler(en);
+ final EntityInvocationHandler entity = (EntityInvocationHandler) Proxy.getInvocationHandler(en);
if (entityContext.isAttached(entity)) {
entityContext.setStatus(entity, AttachedEntityStatus.DELETED);
} else {
@@ -426,7 +430,7 @@ class EntitySetInvocationHandler<
}
}
- private boolean isDeleted(final EntityTypeInvocationHandler handler) {
+ private boolean isDeleted(final EntityInvocationHandler handler) {
return EntityContainerFactory.getContext().entityContext().getStatus(handler) == AttachedEntityStatus.DELETED;
}
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 cdc0bfba2..69e1f9baf 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
@@ -55,7 +55,7 @@ class OperationInvocationHandler extends AbstractInvocationHandler implements Op
return new OperationInvocationHandler(containerHandler);
}
- static OperationInvocationHandler getInstance(final EntityTypeInvocationHandler entityHandler) {
+ static OperationInvocationHandler getInstance(final EntityInvocationHandler entityHandler) {
return new OperationInvocationHandler(entityHandler);
}
@@ -74,7 +74,7 @@ class OperationInvocationHandler extends AbstractInvocationHandler implements Op
this.serviceRoot = containerHandler.getFactory().getServiceRoot();
}
- private OperationInvocationHandler(final EntityTypeInvocationHandler entityHandler) {
+ private OperationInvocationHandler(final EntityInvocationHandler entityHandler) {
super(entityHandler.getClient(), entityHandler.containerHandler);
this.target = entityHandler;
@@ -128,7 +128,7 @@ class OperationInvocationHandler extends AbstractInvocationHandler implements Op
final Map.Entry edmOperation;
if (target instanceof EntityContainerInvocationHandler) {
edmOperation = getUnboundOperation(operation, parameterNames);
- } else if (target instanceof EntityTypeInvocationHandler) {
+ } else if (target instanceof EntityInvocationHandler) {
edmOperation = getBoundOperation(operation, parameterNames);
} else if (target instanceof EntityCollectionInvocationHandler) {
edmOperation = getCollectionBoundOperation(operation, parameterNames);
@@ -161,7 +161,7 @@ class OperationInvocationHandler extends AbstractInvocationHandler implements Op
}
private Map.Entry getBoundOperation(final Operation operation, final List parameterNames) {
- final CommonODataEntity entity = ((EntityTypeInvocationHandler) target).getEntity();
+ final CommonODataEntity entity = ((EntityInvocationHandler) target).getEntity();
ODataOperation boundOp = entity.getOperation(operation.name());
if (boundOp == null) {
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java
index 4ec75eb1d..57b1b3988 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java
@@ -22,7 +22,6 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
import org.apache.olingo.ext.proxy.api.AbstractSingleton;
-import org.apache.olingo.ext.proxy.api.annotations.Singleton;
public class SingletonInvocationHandler<
T extends Serializable, KEY extends Serializable, EC extends AbstractEntityCollection>
@@ -33,18 +32,19 @@ public class SingletonInvocationHandler<
@SuppressWarnings({"rawtypes", "unchecked"})
static SingletonInvocationHandler getInstance(
- final Class> ref, final EntityContainerInvocationHandler containerHandler) {
+ final Class> ref, final EntityContainerInvocationHandler containerHandler, final String singletonName) {
- return new SingletonInvocationHandler(ref, containerHandler);
+ return new SingletonInvocationHandler(ref, containerHandler, singletonName);
}
private final EntitySetInvocationHandler, ?, ?> entitySetHandler;
@SuppressWarnings({"rawtypes", "unchecked"})
- private SingletonInvocationHandler(final Class> ref, final EntityContainerInvocationHandler containerHandler) {
+ private SingletonInvocationHandler(
+ final Class> ref, final EntityContainerInvocationHandler containerHandler, final String singletonName) {
+
super(containerHandler.getClient(), containerHandler);
- this.entitySetHandler =
- new EntitySetInvocationHandler(ref, containerHandler, (ref.getAnnotation(Singleton.class)).name());
+ this.entitySetHandler = EntitySetInvocationHandler.getInstance(ref, containerHandler, singletonName);
}
@Override
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java
index 96cad427a..8126bcc96 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java
@@ -18,20 +18,20 @@
*/
package org.apache.olingo.ext.proxy.context;
-import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
public class AttachedEntity {
- private final EntityTypeInvocationHandler entity;
+ private final EntityInvocationHandler entity;
private final AttachedEntityStatus status;
- public AttachedEntity(final EntityTypeInvocationHandler entity, final AttachedEntityStatus status) {
+ public AttachedEntity(final EntityInvocationHandler entity, final AttachedEntityStatus status) {
this.entity = entity;
this.status = status;
}
- public EntityTypeInvocationHandler getEntity() {
+ public EntityInvocationHandler getEntity() {
return entity;
}
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java
index ab2c9a899..2b42cd16e 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java
@@ -24,7 +24,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
/**
* Entity context.
@@ -36,16 +36,16 @@ public class EntityContext implements Iterable {
*
* This map have to be used to search for entities by key.
*/
- private final Map searchableEntities =
- new HashMap();
+ private final Map searchableEntities =
+ new HashMap();
/**
* All attached entities (new entities included).
*
* Attachment order will be maintained.
*/
- private final Map allAttachedEntities =
- new LinkedHashMap();
+ private final Map allAttachedEntities =
+ new LinkedHashMap();
/**
* Attaches an entity with status NEW.
@@ -55,7 +55,7 @@ public class EntityContext implements Iterable {
* @see AttachedEntityStatus
* @param entity entity to be attached.
*/
- public void attachNew(final EntityTypeInvocationHandler entity) {
+ public void attachNew(final EntityInvocationHandler entity) {
if (allAttachedEntities.containsKey(entity)) {
throw new IllegalStateException("An entity with the same key has already been attached");
}
@@ -70,7 +70,7 @@ public class EntityContext implements Iterable {
* @see AttachedEntityStatus
* @param entity entity to be attached.
*/
- public void attach(final EntityTypeInvocationHandler entity) {
+ public void attach(final EntityInvocationHandler entity) {
attach(entity, AttachedEntityStatus.ATTACHED);
}
@@ -83,7 +83,7 @@ public class EntityContext implements Iterable {
* @param entity entity to be attached.
* @param status status.
*/
- public void attach(final EntityTypeInvocationHandler entity, final AttachedEntityStatus status) {
+ public void attach(final EntityInvocationHandler entity, final AttachedEntityStatus status) {
if (isAttached(entity)) {
throw new IllegalStateException("An entity with the same profile has already been attached");
}
@@ -100,7 +100,7 @@ public class EntityContext implements Iterable {
*
* @param entity entity to be detached.
*/
- public void detach(final EntityTypeInvocationHandler entity) {
+ public void detach(final EntityInvocationHandler entity) {
if (searchableEntities.containsKey(entity.getUUID())) {
searchableEntities.remove(entity.getUUID());
}
@@ -123,7 +123,7 @@ public class EntityContext implements Iterable {
* @param uuid entity key.
* @return retrieved entity.
*/
- public EntityTypeInvocationHandler getEntity(final EntityUUID uuid) {
+ public EntityInvocationHandler getEntity(final EntityUUID uuid) {
return searchableEntities.get(uuid);
}
@@ -133,7 +133,7 @@ public class EntityContext implements Iterable {
* @param entity entity to be retrieved.
* @return attached entity status.
*/
- public AttachedEntityStatus getStatus(final EntityTypeInvocationHandler entity) {
+ public AttachedEntityStatus getStatus(final EntityInvocationHandler entity) {
if (!isAttached(entity)) {
throw new IllegalStateException("Entity is not in the context");
}
@@ -147,7 +147,7 @@ public class EntityContext implements Iterable {
* @param entity attached entity to be modified.
* @param status new status.
*/
- public void setStatus(final EntityTypeInvocationHandler entity, final AttachedEntityStatus status) {
+ public void setStatus(final EntityInvocationHandler entity, final AttachedEntityStatus status) {
if (!isAttached(entity)) {
throw new IllegalStateException("Entity is not in the context");
}
@@ -177,7 +177,7 @@ public class EntityContext implements Iterable {
* @param entity entity.
* @return true if is attached; false otherwise.
*/
- public boolean isAttached(final EntityTypeInvocationHandler entity) {
+ public boolean isAttached(final EntityInvocationHandler entity) {
return allAttachedEntities.containsKey(entity)
|| (entity.getUUID().getKey() != null && searchableEntities.containsKey(entity.getUUID()));
}
@@ -190,7 +190,7 @@ public class EntityContext implements Iterable {
@Override
public Iterator iterator() {
final List res = new ArrayList();
- for (Map.Entry attachedEntity : allAttachedEntities.
+ for (Map.Entry attachedEntity : allAttachedEntities.
entrySet()) {
res.add(new AttachedEntity(attachedEntity.getKey(), attachedEntity.getValue()));
}
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java
index 791f471ac..3c8daddc9 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java
@@ -26,7 +26,7 @@ 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.commons.api.domain.ODataLinkType;
-import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
public class EntityLinkDesc implements Serializable {
@@ -34,16 +34,16 @@ public class EntityLinkDesc implements Serializable {
private final String sourceName;
- private final EntityTypeInvocationHandler source;
+ private final EntityInvocationHandler source;
- private final Collection targets;
+ private final Collection targets;
private final ODataLinkType type;
public EntityLinkDesc(
final String sourceName,
- final EntityTypeInvocationHandler source,
- final Collection target,
+ final EntityInvocationHandler source,
+ final Collection target,
final ODataLinkType type) {
this.sourceName = sourceName;
this.source = source;
@@ -53,12 +53,12 @@ public class EntityLinkDesc implements Serializable {
public EntityLinkDesc(
final String sourceName,
- final EntityTypeInvocationHandler source,
- final EntityTypeInvocationHandler target,
+ final EntityInvocationHandler source,
+ final EntityInvocationHandler target,
final ODataLinkType type) {
this.sourceName = sourceName;
this.source = source;
- this.targets = Collections.singleton(target);
+ this.targets = Collections.singleton(target);
this.type = type;
}
@@ -66,11 +66,11 @@ public class EntityLinkDesc implements Serializable {
return sourceName;
}
- public EntityTypeInvocationHandler getSource() {
+ public EntityInvocationHandler getSource() {
return source;
}
- public Collection getTargets() {
+ public Collection getTargets() {
return targets;
}
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityUUID.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityUUID.java
index cc39d4cd8..edfc227c2 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityUUID.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityUUID.java
@@ -19,6 +19,7 @@
package org.apache.olingo.ext.proxy.context;
import java.io.Serializable;
+import java.net.URI;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
@@ -32,7 +33,7 @@ public class EntityUUID implements Serializable {
private final String containerName;
- private final String entitySetName;
+ private final URI entitySetURI;
private final Object key;
@@ -43,13 +44,13 @@ public class EntityUUID implements Serializable {
private Class> type;
- public EntityUUID(final String containerName, final String entitySetName, final Class> type) {
- this(containerName, entitySetName, type, null);
+ public EntityUUID(final String containerName, final URI entitySetURI, final Class> type) {
+ this(containerName, entitySetURI, type, null);
}
- public EntityUUID(final String containerName, final String entitySetName, final Class> type, final Object key) {
+ public EntityUUID(final String containerName, final URI entitySetURI, final Class> type, final Object key) {
this.containerName = containerName;
- this.entitySetName = entitySetName;
+ this.entitySetURI = entitySetURI;
this.key = key;
this.tempKey = (int) (Math.random() * 1000000);
@@ -70,8 +71,8 @@ public class EntityUUID implements Serializable {
return containerName;
}
- public String getEntitySetName() {
- return entitySetName;
+ public URI getEntitySetURI() {
+ return entitySetURI;
}
public Object getKey() {
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 cda964e1e..38dd4ccb5 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
@@ -60,9 +60,9 @@ import org.apache.olingo.ext.proxy.api.annotations.EnumType;
import org.apache.olingo.ext.proxy.api.annotations.Key;
import org.apache.olingo.ext.proxy.api.annotations.Namespace;
import org.apache.olingo.ext.proxy.api.annotations.Property;
-import org.apache.olingo.ext.proxy.commons.AbstractTypeInvocationHandler;
-import org.apache.olingo.ext.proxy.commons.ComplexTypeInvocationHandler;
-import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.AbstractStructuredInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.ComplexInvocationHandler;
+import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -112,10 +112,10 @@ public final class CoreUtils {
} else {
objHandler = obj;
}
- if (objHandler instanceof ComplexTypeInvocationHandler) {
- value = ((ComplexTypeInvocationHandler) objHandler).getComplex();
+ if (objHandler instanceof ComplexInvocationHandler) {
+ value = ((ComplexInvocationHandler) objHandler).getComplex();
- final Class> typeRef = ((ComplexTypeInvocationHandler) objHandler).getTypeRef();
+ final Class> typeRef = ((ComplexInvocationHandler) objHandler).getTypeRef();
for (Method method : typeRef.getMethods()) {
final Property propAnn = method.getAnnotation(Property.class);
if (propAnn != null) {
@@ -385,8 +385,8 @@ public final class CoreUtils {
final Class> typeRef;
if (bean instanceof Proxy) {
final InvocationHandler handler = Proxy.getInvocationHandler(bean);
- if (handler instanceof AbstractTypeInvocationHandler) {
- typeRef = ((ComplexTypeInvocationHandler) handler).getTypeRef();
+ if (handler instanceof AbstractStructuredInvocationHandler) {
+ typeRef = ((ComplexInvocationHandler) handler).getTypeRef();
} else {
throw new IllegalStateException("Invalid bean " + bean);
}
@@ -425,7 +425,7 @@ public final class CoreUtils {
final Object complex = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class>[] {getter.getReturnType()},
- ComplexTypeInvocationHandler.getInstance(
+ ComplexInvocationHandler.getInstance(
client, property.getName(), getter.getReturnType(), null));
populate(client, complex, Property.class, property.getValue().asComplex().iterator());
@@ -450,7 +450,7 @@ public final class CoreUtils {
final Object collItem = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class>[] {collItemClass},
- ComplexTypeInvocationHandler.getInstance(
+ ComplexInvocationHandler.getInstance(
client, property.getName(), collItemClass, null));
populate(client, collItem, Property.class, value.asComplex().iterator());
@@ -471,7 +471,7 @@ public final class CoreUtils {
final CommonEdmEnabledODataClient> client,
final CommonODataProperty property,
final Type typeRef,
- final EntityTypeInvocationHandler entityHandler)
+ final EntityInvocationHandler entityHandler)
throws InstantiationException, IllegalAccessException {
Class> internalRef;
@@ -495,7 +495,7 @@ public final class CoreUtils {
res = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class>[] {internalRef},
- ComplexTypeInvocationHandler.getInstance(
+ ComplexInvocationHandler.getInstance(
client, property.getValue().asComplex(), internalRef, entityHandler));
} else if (property.hasCollectionValue()) {
final ArrayList