You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/05/14 15:45:34 UTC
[1/2] [OLINGO-261][OLINGO-260] Improving singleton handling
Repository: olingo-odata4
Updated Branches:
refs/heads/master 99cd23fbc -> 6e9fb661c
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Company.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Company.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Company.java
index 0b985c5..4ed2761 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Company.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Company.java
@@ -18,7 +18,7 @@
*/
package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice;
-import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
+import org.apache.olingo.ext.proxy.api.AbstractSingleton;
import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
import org.apache.olingo.ext.proxy.api.annotations.Singleton;
import org.apache.olingo.ext.proxy.api.annotations.CompoundKey;
@@ -44,9 +44,5 @@ import java.util.Calendar;
@Singleton(name = "Company")
-public interface Company extends AbstractEntitySet<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyCollection> {
-
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company newCompany();
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PublicCompany newPublicCompany();
+public interface Company extends AbstractSingleton<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyCollection> {
}
-
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/DefaultStoredPI.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/DefaultStoredPI.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/DefaultStoredPI.java
index 85c7818..9d50353 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/DefaultStoredPI.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/DefaultStoredPI.java
@@ -18,7 +18,7 @@
*/
package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice;
-import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
+import org.apache.olingo.ext.proxy.api.AbstractSingleton;
import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
import org.apache.olingo.ext.proxy.api.annotations.Singleton;
import org.apache.olingo.ext.proxy.api.annotations.CompoundKey;
@@ -44,8 +44,5 @@ import java.util.Calendar;
@Singleton(name = "DefaultStoredPI")
-public interface DefaultStoredPI extends AbstractEntitySet<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.StoredPI, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.StoredPICollection> {
-
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.StoredPI newStoredPI();
+public interface DefaultStoredPI extends AbstractSingleton<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.StoredPI, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.StoredPICollection> {
}
-
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/LabourUnion.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/LabourUnion.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/LabourUnion.java
index ff9be59..3aa2ddf 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/LabourUnion.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/LabourUnion.java
@@ -18,7 +18,7 @@
*/
package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice;
-import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
+import org.apache.olingo.ext.proxy.api.AbstractSingleton;
import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
import org.apache.olingo.ext.proxy.api.annotations.Singleton;
import org.apache.olingo.ext.proxy.api.annotations.CompoundKey;
@@ -44,8 +44,5 @@ import java.util.Calendar;
@Singleton(name = "LabourUnion")
-public interface LabourUnion extends AbstractEntitySet<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.LabourUnion, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.LabourUnionCollection> {
-
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.LabourUnion newLabourUnion();
+public interface LabourUnion extends AbstractSingleton<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.LabourUnion, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.LabourUnionCollection> {
}
-
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/PublicCompany.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/PublicCompany.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/PublicCompany.java
index e75abd6..e44d0e5 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/PublicCompany.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/PublicCompany.java
@@ -18,7 +18,7 @@
*/
package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice;
-import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
+import org.apache.olingo.ext.proxy.api.AbstractSingleton;
import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
import org.apache.olingo.ext.proxy.api.annotations.Singleton;
import org.apache.olingo.ext.proxy.api.annotations.CompoundKey;
@@ -44,9 +44,5 @@ import java.util.Calendar;
@Singleton(name = "PublicCompany")
-public interface PublicCompany extends AbstractEntitySet<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyCollection> {
-
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company newCompany();
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PublicCompany newPublicCompany();
+public interface PublicCompany extends AbstractSingleton<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyCollection> {
}
-
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/VipCustomer.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/VipCustomer.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/VipCustomer.java
index 04808c4..ddee96b 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/VipCustomer.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/VipCustomer.java
@@ -18,7 +18,7 @@
*/
package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice;
-import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
+import org.apache.olingo.ext.proxy.api.AbstractSingleton;
import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
import org.apache.olingo.ext.proxy.api.annotations.Singleton;
import org.apache.olingo.ext.proxy.api.annotations.CompoundKey;
@@ -44,8 +44,5 @@ import java.util.Calendar;
@Singleton(name = "VipCustomer")
-public interface VipCustomer extends AbstractEntitySet<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CustomerCollection> {
-
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer newCustomer();
+public interface VipCustomer extends AbstractSingleton<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CustomerCollection> {
}
-
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/OrderDetail.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/OrderDetail.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/OrderDetail.java
index 9d51dc7..e74df1e 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/OrderDetail.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/OrderDetail.java
@@ -59,6 +59,8 @@ import javax.xml.datatype.Duration;
public interface OrderDetail
extends Serializable {
+
+ @Key
@Property(name = "OrderID",
type = "Edm.Int32",
nullable = false,
[2/2] git commit: [OLINGO-261][OLINGO-260] Improving singleton
handling
Posted by il...@apache.org.
[OLINGO-261][OLINGO-260] Improving singleton handling
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/6e9fb661
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/6e9fb661
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/6e9fb661
Branch: refs/heads/master
Commit: 6e9fb661c0514885620415dcc694f63a14ec4f40
Parents: 99cd23f
Author: Francesco Chicchiriccò <--global>
Authored: Wed May 14 15:45:26 2014 +0200
Committer: Francesco Chicchiriccò <--global>
Committed: Wed May 14 15:45:26 2014 +0200
----------------------------------------------------------------------
.../ext/proxy/api/AbstractEntityCollection.java | 2 +-
.../olingo/ext/proxy/api/AbstractEntitySet.java | 2 +-
.../olingo/ext/proxy/api/AbstractOpenType.java | 2 +-
.../olingo/ext/proxy/api/AbstractSingleton.java | 33 +++++
.../commons/AbstractInvocationHandler.java | 22 ++--
.../commons/AbstractTypeInvocationHandler.java | 20 ++-
.../commons/ComplexTypeInvocationHandler.java | 22 ++--
.../olingo/ext/proxy/commons/ContainerImpl.java | 36 ++---
.../EntityCollectionInvocationHandler.java | 41 +++---
.../EntityContainerInvocationHandler.java | 35 +++--
.../commons/EntitySetInvocationHandler.java | 130 +++++++------------
.../ext/proxy/commons/EntitySetIterator.java | 4 +-
.../commons/EntityTypeInvocationHandler.java | 17 +--
.../proxy/commons/FactoryInvocationHandler.java | 35 ++---
.../commons/OperationInvocationHandler.java | 38 ++----
.../commons/SingletonInvocationHandler.java | 64 +++++++++
.../ext/proxy/context/AttachedEntity.java | 6 +-
.../olingo/ext/proxy/context/EntityContext.java | 26 ++--
.../ext/proxy/context/EntityLinkDesc.java | 18 +--
.../olingo/ext/proxy/utils/CoreUtils.java | 10 +-
.../src/main/resources/singleton.vm | 2 +-
.../src/main/resources/v40/singleton.vm | 10 +-
.../olingo/fit/proxy/v3/ContextTestITCase.java | 16 +--
.../v4/BoundOperationInvokeTestITCase.java | 6 +-
.../fit/proxy/v4/SingletonTestITCase.java | 15 +--
.../odata/services/odatawcfservice/Boss.java | 9 +-
.../odata/services/odatawcfservice/Company.java | 8 +-
.../odatawcfservice/DefaultStoredPI.java | 7 +-
.../services/odatawcfservice/LabourUnion.java | 7 +-
.../services/odatawcfservice/PublicCompany.java | 8 +-
.../services/odatawcfservice/VipCustomer.java | 7 +-
.../odatawcfservice/types/OrderDetail.java | 2 +
32 files changed, 330 insertions(+), 330 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntityCollection.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntityCollection.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntityCollection.java
index 3dc3719..39aba85 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntityCollection.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntityCollection.java
@@ -21,5 +21,5 @@ package org.apache.olingo.ext.proxy.api;
import java.io.Serializable;
import java.util.Collection;
-public abstract interface AbstractEntityCollection<T extends Serializable> extends Collection<T>, Serializable {
+public interface AbstractEntityCollection<T extends Serializable> extends Collection<T>, Serializable {
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
index b4df7c9..6f22164 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractEntitySet.java
@@ -23,7 +23,7 @@ import java.io.Serializable;
/**
* Interface for synchronous CRUD operations on an EntitySet.
*/
-public abstract interface AbstractEntitySet<
+public interface AbstractEntitySet<
T extends Serializable, KEY extends Serializable, EC extends AbstractEntityCollection<T>>
extends Iterable<T>, Serializable {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractOpenType.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractOpenType.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractOpenType.java
index 4b200b4..c2f565c 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractOpenType.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractOpenType.java
@@ -21,7 +21,7 @@ package org.apache.olingo.ext.proxy.api;
import java.io.Serializable;
import java.util.Collection;
-public abstract interface AbstractOpenType extends Serializable {
+public interface AbstractOpenType extends Serializable {
void addAdditionalProperty(String name, Object value);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractSingleton.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractSingleton.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractSingleton.java
new file mode 100644
index 0000000..fb2feca
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractSingleton.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.ext.proxy.api;
+
+import java.io.Serializable;
+
+public interface AbstractSingleton<
+ T extends Serializable, KEY extends Serializable, EC extends AbstractEntityCollection<T>>
+ extends Serializable {
+
+ /**
+ * Retrieves a singleton.
+ *
+ * @return the singleton
+ */
+ T get();
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java
index 516664d..5181b48 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
@@ -26,7 +26,6 @@ import java.lang.reflect.Proxy;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -50,22 +49,22 @@ import org.apache.olingo.ext.proxy.api.annotations.Parameter;
import org.apache.olingo.ext.proxy.utils.ClassUtils;
import org.apache.olingo.ext.proxy.utils.CoreUtils;
-abstract class AbstractInvocationHandler<C extends CommonEdmEnabledODataClient<?>> implements InvocationHandler {
+abstract class AbstractInvocationHandler implements InvocationHandler {
private static final long serialVersionUID = 358520026931462958L;
- protected final C client;
+ protected final CommonEdmEnabledODataClient<?> client;
- protected EntityContainerInvocationHandler<C> containerHandler;
+ protected EntityContainerInvocationHandler containerHandler;
protected AbstractInvocationHandler(
- final C client, final EntityContainerInvocationHandler<C> containerHandler) {
+ final CommonEdmEnabledODataClient<?> client, final EntityContainerInvocationHandler containerHandler) {
this.client = client;
this.containerHandler = containerHandler;
}
- protected C getClient() {
+ protected CommonEdmEnabledODataClient<?> getClient() {
return client;
}
@@ -106,7 +105,7 @@ abstract class AbstractInvocationHandler<C extends CommonEdmEnabledODataClient<?
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {typeCollectionRef},
- new EntityCollectionInvocationHandler(containerHandler, items, typeRef, entityContainerName, uri));
+ new EntityCollectionInvocationHandler(containerHandler, items, typeRef, uri));
}
protected <T> T getEntityProxy(
@@ -128,8 +127,8 @@ abstract class AbstractInvocationHandler<C extends CommonEdmEnabledODataClient<?
final String eTag,
final boolean checkInTheContext) {
- EntityTypeInvocationHandler<C> handler = (EntityTypeInvocationHandler<C>) EntityTypeInvocationHandler.getInstance(
- entity, entitySetName, type, containerHandler);
+ EntityTypeInvocationHandler handler =
+ EntityTypeInvocationHandler.getInstance(entity, entitySetName, type, containerHandler);
if (StringUtils.isNotBlank(eTag)) {
// override ETag into the wrapped object.
@@ -137,8 +136,7 @@ abstract class AbstractInvocationHandler<C extends CommonEdmEnabledODataClient<?
}
if (checkInTheContext && EntityContainerFactory.getContext().entityContext().isAttached(handler)) {
- handler = (EntityTypeInvocationHandler<C>) EntityContainerFactory.getContext().entityContext().
- getEntity(handler.getUUID());
+ handler = EntityContainerFactory.getContext().entityContext().getEntity(handler.getUUID());
}
return (T) Proxy.newProxyInstance(
@@ -157,7 +155,7 @@ abstract class AbstractInvocationHandler<C extends CommonEdmEnabledODataClient<?
IllegalArgumentException, InvocationTargetException {
// 1. invoke params (if present)
- final Map<String, ODataValue> parameterValues = new HashMap<String, ODataValue>();
+ final Map<String, ODataValue> parameterValues = new LinkedHashMap<String, ODataValue>();
if (!parameters.isEmpty()) {
for (Map.Entry<Parameter, Object> parameter : parameters.entrySet()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractTypeInvocationHandler.java
----------------------------------------------------------------------
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/AbstractTypeInvocationHandler.java
index d9a9d85..4fd5a7e 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/AbstractTypeInvocationHandler.java
@@ -47,8 +47,7 @@ import org.apache.olingo.ext.proxy.utils.ClassUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AbstractTypeInvocationHandler<C extends CommonEdmEnabledODataClient<?>>
- extends AbstractInvocationHandler<C> {
+public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
@@ -61,16 +60,15 @@ public abstract class AbstractTypeInvocationHandler<C extends CommonEdmEnabledOD
protected final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
- protected final EntityTypeInvocationHandler<C> targetHandler;
+ protected final EntityTypeInvocationHandler targetHandler;
protected Object internal;
- @SuppressWarnings("unchecked")
protected AbstractTypeInvocationHandler(
- final C client,
+ final CommonEdmEnabledODataClient<?> client,
final Class<?> typeRef,
final Object internal,
- final EntityContainerInvocationHandler<C> containerHandler) {
+ final EntityContainerInvocationHandler containerHandler) {
super(client, containerHandler);
this.internal = internal;
@@ -79,10 +77,10 @@ public abstract class AbstractTypeInvocationHandler<C extends CommonEdmEnabledOD
}
protected AbstractTypeInvocationHandler(
- final C client,
+ final CommonEdmEnabledODataClient<?> client,
final Class<?> typeRef,
final Object internal,
- final EntityTypeInvocationHandler<C> targetHandler) {
+ final EntityTypeInvocationHandler targetHandler) {
super(client, targetHandler == null ? null : targetHandler.containerHandler);
this.internal = internal;
@@ -97,7 +95,6 @@ public abstract class AbstractTypeInvocationHandler<C extends CommonEdmEnabledOD
}
@Override
- @SuppressWarnings("unchecked")
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
if (isSelfMethod(method, args)) {
return invokeSelfMethod(method, args);
@@ -163,7 +160,7 @@ public abstract class AbstractTypeInvocationHandler<C extends CommonEdmEnabledOD
return ClassUtils.returnVoid();
} else {
- throw new UnsupportedOperationException("Method not found: " + method);
+ throw new NoSuchMethodException(method.getName());
}
}
@@ -282,8 +279,7 @@ public abstract class AbstractTypeInvocationHandler<C extends CommonEdmEnabledOD
throw new IllegalArgumentException("Invalid argument type");
}
- @SuppressWarnings("unchecked")
- final EntityTypeInvocationHandler<C> linkedHandler = (EntityTypeInvocationHandler<C>) etih;
+ final EntityTypeInvocationHandler linkedHandler = (EntityTypeInvocationHandler) etih;
if (!linkedHandler.getTypeRef().isAnnotationPresent(EntityType.class)) {
throw new IllegalArgumentException("Invalid argument type " + linkedHandler.getTypeRef().getSimpleName());
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexTypeInvocationHandler.java
----------------------------------------------------------------------
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/ComplexTypeInvocationHandler.java
index fe645ae..69de2ea 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/ComplexTypeInvocationHandler.java
@@ -41,17 +41,16 @@ 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<C extends CommonEdmEnabledODataClient<?>>
- extends AbstractTypeInvocationHandler<C> {
+public class ComplexTypeInvocationHandler extends AbstractTypeInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
- public static ComplexTypeInvocationHandler<?> getInstance(
+ public static ComplexTypeInvocationHandler getInstance(
final CommonEdmEnabledODataClient<?> client,
final String propertyName,
final Class<?> reference,
- final EntityTypeInvocationHandler<?> handler) {
-
+ final EntityTypeInvocationHandler handler) {
+
final Class<?> complexTypeRef;
if (Collection.class.isAssignableFrom(reference)) {
complexTypeRef = ClassUtils.extractTypeArg(reference);
@@ -70,25 +69,24 @@ public class ComplexTypeInvocationHandler<C extends CommonEdmEnabledODataClient<
final ODataComplexValue<? extends CommonODataProperty> complex =
client.getObjectFactory().newComplexValue(typeName.toString());
- return (ComplexTypeInvocationHandler<?>) ComplexTypeInvocationHandler.getInstance(
+ return (ComplexTypeInvocationHandler) ComplexTypeInvocationHandler.getInstance(
client, complex, complexTypeRef, handler);
}
- @SuppressWarnings({"unchecked", "rawtypes"})
- public static ComplexTypeInvocationHandler<?> getInstance(
+ public static ComplexTypeInvocationHandler getInstance(
final CommonEdmEnabledODataClient<?> client,
final ODataComplexValue<?> complex,
final Class<?> typeRef,
- final EntityTypeInvocationHandler<?> handler) {
+ final EntityTypeInvocationHandler handler) {
return new ComplexTypeInvocationHandler(client, complex, typeRef, handler);
}
public ComplexTypeInvocationHandler(
- final C client,
+ final CommonEdmEnabledODataClient<?> client,
final ODataComplexValue<?> complex,
final Class<?> typeRef,
- final EntityTypeInvocationHandler<C> handler) {
+ final EntityTypeInvocationHandler handler) {
super(client, typeRef, complex, handler);
}
@@ -163,7 +161,7 @@ public class ComplexTypeInvocationHandler<C extends CommonEdmEnabledODataClient<
final EdmTypeInfo type = new EdmTypeInfo.Builder().
setEdm(client.getCachedEdm()).setTypeExpression(
- edmProperty.isCollection() ? "Collection(" + property.type() + ")" : property.type()).build();
+ edmProperty.isCollection() ? "Collection(" + property.type() + ")" : property.type()).build();
client.getBinder().add(
getComplex(), CoreUtils.getODataProperty(client, property.name(), type, toBeAdded));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java
index 49c1c9f..ab824ec 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
@@ -138,7 +138,7 @@ class ContainerImpl implements Container {
throw new IllegalStateException("Transaction failed: " + res.getStatusMessage());
}
- final EntityTypeInvocationHandler<?> handler = items.get(changesetItemId);
+ final EntityTypeInvocationHandler handler = items.get(changesetItemId);
if (handler != null) {
if (res instanceof ODataEntityCreateResponse) {
@@ -156,7 +156,7 @@ class ContainerImpl implements Container {
}
private void batch(
- final EntityTypeInvocationHandler<?> handler,
+ final EntityTypeInvocationHandler handler,
final CommonODataEntity entity,
final ODataChangeset changeset) {
@@ -181,7 +181,7 @@ class ContainerImpl implements Container {
}
private void batchCreate(
- final EntityTypeInvocationHandler<?> handler,
+ final EntityTypeInvocationHandler handler,
final CommonODataEntity entity,
final ODataChangeset changeset) {
@@ -193,7 +193,7 @@ class ContainerImpl implements Container {
}
private void batchUpdateMediaEntity(
- final EntityTypeInvocationHandler<?> handler,
+ final EntityTypeInvocationHandler handler,
final URI uri,
final InputStream input,
final ODataChangeset changeset) {
@@ -215,7 +215,7 @@ class ContainerImpl implements Container {
}
private void batchUpdateMediaResource(
- final EntityTypeInvocationHandler<?> handler,
+ final EntityTypeInvocationHandler handler,
final URI uri,
final InputStream input,
final ODataChangeset changeset) {
@@ -232,7 +232,7 @@ class ContainerImpl implements Container {
}
private void batchUpdate(
- final EntityTypeInvocationHandler<?> handler,
+ final EntityTypeInvocationHandler handler,
final CommonODataEntity changes,
final ODataChangeset changeset) {
@@ -255,7 +255,7 @@ class ContainerImpl implements Container {
}
private void batchUpdate(
- final EntityTypeInvocationHandler<?> handler,
+ final EntityTypeInvocationHandler handler,
final URI uri,
final CommonODataEntity changes,
final ODataChangeset changeset) {
@@ -281,7 +281,7 @@ class ContainerImpl implements Container {
}
private void batchDelete(
- final EntityTypeInvocationHandler<?> handler,
+ final EntityTypeInvocationHandler handler,
final CommonODataEntity entity,
final ODataChangeset changeset) {
@@ -298,7 +298,7 @@ class ContainerImpl implements Container {
}
private int processEntityContext(
- final EntityTypeInvocationHandler<?> handler,
+ final EntityTypeInvocationHandler handler,
int pos,
final TransactionItems items,
final List<EntityLinkDesc> delayedUpdates,
@@ -323,13 +323,13 @@ class ContainerImpl implements Container {
? ODataLinkType.ENTITY_SET_NAVIGATION
: ODataLinkType.ENTITY_NAVIGATION;
- final Set<EntityTypeInvocationHandler<?>> toBeLinked = new HashSet<EntityTypeInvocationHandler<?>>();
+ final Set<EntityTypeInvocationHandler> toBeLinked = new HashSet<EntityTypeInvocationHandler>();
final String serviceRoot = factory.getServiceRoot();
for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
? (Collection) property.getValue() : Collections.singleton(property.getValue())) {
- final EntityTypeInvocationHandler<?> target =
+ final EntityTypeInvocationHandler target =
(EntityTypeInvocationHandler) Proxy.getInvocationHandler(proxy);
final AttachedEntityStatus status =
@@ -467,7 +467,7 @@ class ContainerImpl implements Container {
sourceURI = URI.create("$" + sourcePos);
}
- for (EntityTypeInvocationHandler<?> target : delayedUpdate.getTargets()) {
+ for (EntityTypeInvocationHandler target : delayedUpdate.getTargets()) {
status = EntityContainerFactory.getContext().entityContext().getStatus(target);
final URI targetURI;
@@ -492,11 +492,11 @@ class ContainerImpl implements Container {
private class TransactionItems {
- private final List<EntityTypeInvocationHandler<?>> keys = new ArrayList<EntityTypeInvocationHandler<?>>();
+ private final List<EntityTypeInvocationHandler> keys = new ArrayList<EntityTypeInvocationHandler>();
private final List<Integer> values = new ArrayList<Integer>();
- public EntityTypeInvocationHandler<?> get(final Integer value) {
+ public EntityTypeInvocationHandler get(final Integer value) {
if (value != null && values.contains(value)) {
return keys.get(values.indexOf(value));
} else {
@@ -504,7 +504,7 @@ class ContainerImpl implements Container {
}
}
- public Integer get(final EntityTypeInvocationHandler<?> key) {
+ public Integer get(final EntityTypeInvocationHandler key) {
if (key != null && keys.contains(key)) {
return values.get(keys.indexOf(key));
} else {
@@ -512,14 +512,14 @@ class ContainerImpl implements Container {
}
}
- public void remove(final EntityTypeInvocationHandler<?> key) {
+ public void remove(final EntityTypeInvocationHandler key) {
if (keys.contains(key)) {
values.remove(keys.indexOf(key));
keys.remove(key);
}
}
- public void put(final EntityTypeInvocationHandler<?> key, final Integer value) {
+ public void put(final EntityTypeInvocationHandler key, final Integer value) {
// replace just in case of null current value; otherwise add the new entry
if (key != null && keys.contains(key) && values.get(keys.indexOf(key)) == null) {
remove(key);
@@ -534,7 +534,7 @@ class ContainerImpl implements Container {
return sortedValues;
}
- public boolean contains(final EntityTypeInvocationHandler<?> key) {
+ public boolean contains(final EntityTypeInvocationHandler key) {
return keys.contains(key);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java
index e75056a..06d03a2 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityCollectionInvocationHandler.java
@@ -1,14 +1,20 @@
-/**
- * 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
+/*
+ * 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
+ * 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.
+ * 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;
@@ -19,11 +25,10 @@ import java.net.URI;
import java.util.Collection;
import java.util.Iterator;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
-public class EntityCollectionInvocationHandler<T extends Serializable, C extends CommonEdmEnabledODataClient<?>>
- extends AbstractInvocationHandler<C> implements AbstractEntityCollection<T> {
+public class EntityCollectionInvocationHandler<T extends Serializable>
+ extends AbstractInvocationHandler implements AbstractEntityCollection<T> {
private static final long serialVersionUID = 98078202642671726L;
@@ -33,14 +38,14 @@ public class EntityCollectionInvocationHandler<T extends Serializable, C extends
private final URI uri;
- public EntityCollectionInvocationHandler(final EntityContainerInvocationHandler<C> containerHandler,
- final Collection<T> items, final Class<?> itemRef, final String entityContainerName) {
+ public EntityCollectionInvocationHandler(final EntityContainerInvocationHandler containerHandler,
+ final Collection<T> items, final Class<?> itemRef) {
- this(containerHandler, items, itemRef, entityContainerName, null);
+ this(containerHandler, items, itemRef, null);
}
- public EntityCollectionInvocationHandler(final EntityContainerInvocationHandler<C> containerHandler,
- final Collection<T> items, final Class<?> itemRef, final String entityContainerName, final URI uri) {
+ public EntityCollectionInvocationHandler(final EntityContainerInvocationHandler containerHandler,
+ final Collection<T> items, final Class<?> itemRef, final URI uri) {
super(containerHandler.getClient(), containerHandler);
@@ -69,7 +74,7 @@ public class EntityCollectionInvocationHandler<T extends Serializable, C extends
new Class<?>[] {returnType},
OperationInvocationHandler.getInstance(this));
} else {
- throw new UnsupportedOperationException("Method not found: " + method);
+ throw new NoSuchMethodException(method.getName());
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java
index 0b5a5be..e6b1bfe 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
@@ -25,10 +25,11 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
import org.apache.olingo.ext.proxy.EntityContainerFactory;
import org.apache.olingo.ext.proxy.api.annotations.EntityContainer;
+import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
+import org.apache.olingo.ext.proxy.api.annotations.Singleton;
import org.apache.olingo.ext.proxy.utils.ClassUtils;
-public final class EntityContainerInvocationHandler<C extends CommonEdmEnabledODataClient<?>>
- extends AbstractInvocationHandler<C> {
+public final class EntityContainerInvocationHandler extends AbstractInvocationHandler {
private static final long serialVersionUID = 7379006755693410764L;
@@ -40,16 +41,16 @@ public final class EntityContainerInvocationHandler<C extends CommonEdmEnabledOD
private final boolean defaultEC;
- public static <C extends CommonEdmEnabledODataClient<?>> EntityContainerInvocationHandler<C> getInstance(
- final C client, final Class<?> ref, final EntityContainerFactory factory) {
+ public static EntityContainerInvocationHandler getInstance(
+ final CommonEdmEnabledODataClient<?> client, final Class<?> ref, final EntityContainerFactory factory) {
- final EntityContainerInvocationHandler<C> instance = new EntityContainerInvocationHandler<C>(client, ref, factory);
+ final EntityContainerInvocationHandler instance = new EntityContainerInvocationHandler(client, ref, factory);
instance.containerHandler = instance;
return instance;
}
private EntityContainerInvocationHandler(
- final C client, final Class<?> ref, final EntityContainerFactory factory) {
+ final CommonEdmEnabledODataClient<?> client, final Class<?> ref, final EntityContainerFactory factory) {
super(client, null);
@@ -98,11 +99,23 @@ public final class EntityContainerInvocationHandler<C extends CommonEdmEnabledOD
} else {
final Class<?> returnType = method.getReturnType();
- return Proxy.newProxyInstance(
- Thread.currentThread().getContextClassLoader(),
- new Class<?>[] {returnType},
- EntitySetInvocationHandler.getInstance(returnType, this));
-
+ final EntitySet entitySet = returnType.getAnnotation(EntitySet.class);
+ if (entitySet == null) {
+ final Singleton singleton = returnType.getAnnotation(Singleton.class);
+ if (singleton != null) {
+ return Proxy.newProxyInstance(
+ Thread.currentThread().getContextClassLoader(),
+ new Class<?>[] {returnType},
+ SingletonInvocationHandler.getInstance(returnType, this));
+ }
+ } else {
+ return Proxy.newProxyInstance(
+ Thread.currentThread().getContextClassLoader(),
+ new Class<?>[] {returnType},
+ EntitySetInvocationHandler.getInstance(returnType, this));
+ }
+
+ throw new NoSuchMethodException(method.getName());
}
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
index 209c8ea..bee8d12 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
@@ -33,7 +33,6 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
@@ -45,12 +44,11 @@ import org.apache.olingo.commons.api.format.ODataValueFormat;
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.AbstractSingleton;
import org.apache.olingo.ext.proxy.api.Query;
import org.apache.olingo.ext.proxy.api.annotations.CompoundKey;
import org.apache.olingo.ext.proxy.api.annotations.CompoundKeyElement;
import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
-import org.apache.olingo.ext.proxy.api.annotations.EntityType;
-import org.apache.olingo.ext.proxy.api.annotations.Singleton;
import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
import org.apache.olingo.ext.proxy.context.EntityContext;
import org.apache.olingo.ext.proxy.context.EntityUUID;
@@ -59,9 +57,9 @@ import org.apache.olingo.ext.proxy.utils.CoreUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T extends Serializable,
- KEY extends Serializable, EC extends AbstractEntityCollection<T>>
- extends AbstractInvocationHandler<C>
+class EntitySetInvocationHandler<
+ T extends Serializable, KEY extends Serializable, EC extends AbstractEntityCollection<T>>
+ extends AbstractInvocationHandler
implements AbstractEntitySet<T, KEY, EC> {
private static final long serialVersionUID = 2629912294765040027L;
@@ -71,53 +69,38 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
*/
private static final Logger LOG = LoggerFactory.getLogger(EntitySetInvocationHandler.class);
+ private final String entitySetName;
+
+ private final boolean isSingleton;
+
private final Class<T> typeRef;
private final Class<EC> collTypeRef;
- private final String entitySetName;
-
private final URI uri;
- private boolean isSingleton = false;
-
@SuppressWarnings({"rawtypes", "unchecked"})
static EntitySetInvocationHandler getInstance(
final Class<?> ref, final EntityContainerInvocationHandler containerHandler) {
- return new EntitySetInvocationHandler(ref, containerHandler);
+ return new EntitySetInvocationHandler(ref, containerHandler, (ref.getAnnotation(EntitySet.class)).name());
}
@SuppressWarnings("unchecked")
- private EntitySetInvocationHandler(
+ protected EntitySetInvocationHandler(
final Class<?> ref,
- final EntityContainerInvocationHandler<C> containerHandler) {
+ final EntityContainerInvocationHandler containerHandler,
+ final String entitySetName) {
super(containerHandler.getClient(), containerHandler);
+
+ this.entitySetName = entitySetName;
+ this.isSingleton = AbstractSingleton.class.isAssignableFrom(ref);
- Annotation annotation = ref.getAnnotation(EntitySet.class);
- if (annotation == null) {
- annotation = ref.getAnnotation(Singleton.class);
-
- if (annotation == null) {
- throw new IllegalArgumentException("Return type " + ref.getName()
- + " is not annotated as @" + EntitySet.class.getSimpleName());
- }
-
- this.entitySetName = ((Singleton) annotation).name();
- isSingleton = true;
- } else {
- this.entitySetName = ((EntitySet) annotation).name();
- }
-
- final Type[] abstractEntitySetParams =
- ((ParameterizedType) ref.getGenericInterfaces()[0]).getActualTypeArguments();
+ final Type[] entitySetParams = ((ParameterizedType) ref.getGenericInterfaces()[0]).getActualTypeArguments();
- this.typeRef = (Class<T>) abstractEntitySetParams[0];
- if (typeRef.getAnnotation(EntityType.class) == null) {
- throw new IllegalArgumentException("Invalid entity '" + typeRef.getSimpleName() + "'");
- }
- this.collTypeRef = (Class<EC>) abstractEntitySetParams[2];
+ this.typeRef = (Class<T>) entitySetParams[0];
+ this.collTypeRef = (Class<EC>) entitySetParams[2];
final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(containerHandler.getFactory().getServiceRoot());
@@ -131,19 +114,19 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
this.uri = uriBuilder.build();
}
- Class<T> getTypeRef() {
+ protected Class<T> getTypeRef() {
return typeRef;
}
- Class<EC> getCollTypeRef() {
+ protected Class<EC> getCollTypeRef() {
return collTypeRef;
}
- String getEntitySetName() {
+ protected String getEntitySetName() {
return entitySetName;
}
- URI getUri() {
+ protected URI getURI() {
return uri;
}
@@ -159,7 +142,7 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
return newEntity(method.getReturnType());
}
} else {
- throw new UnsupportedOperationException("Method not found: " + method);
+ throw new NoSuchMethodException(method.getName());
}
}
@@ -168,7 +151,7 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
final CommonODataEntity entity = client.getObjectFactory().newEntity(
new FullQualifiedName(containerHandler.getSchemaName(), ClassUtils.getEntityTypeName(reference)));
- final EntityTypeInvocationHandler<?> handler =
+ final EntityTypeInvocationHandler handler =
EntityTypeInvocationHandler.getInstance(entity, entitySetName, reference, containerHandler);
EntityContainerFactory.getContext().entityContext().attachNew(handler);
@@ -183,27 +166,15 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
return (NEC) Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {reference},
- new EntityCollectionInvocationHandler<T, C>(
- containerHandler, new ArrayList<T>(), typeRef, containerHandler.getEntityContainerName()));
+ new EntityCollectionInvocationHandler<T>(containerHandler, new ArrayList<T>(), typeRef));
}
@Override
public Long count() {
- if (isSingleton) {
- final ODataRetrieveResponse<org.apache.olingo.commons.api.domain.v4.Singleton> res =
- ((ODataClient) client).getRetrieveRequestFactory().getSingletonRequest(uri).execute();
-
- if (res.getBody() == null) {
- return 0l;
- } else {
- return 1l;
- }
- } else {
- final ODataValueRequest req = client.getRetrieveRequestFactory().
- getValueRequest(client.getURIBuilder(this.uri.toASCIIString()).count().build());
- req.setFormat(ODataValueFormat.TEXT);
- return Long.valueOf(req.execute().getBody().asPrimitive().toString());
- }
+ final ODataValueRequest req = client.getRetrieveRequestFactory().
+ getValueRequest(client.getURIBuilder(this.uri.toASCIIString()).count().build());
+ req.setFormat(ODataValueFormat.TEXT);
+ return Long.valueOf(req.execute().getBody().asPrimitive().toString());
}
@Override
@@ -219,7 +190,7 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
return result;
}
- private LinkedHashMap<String, Object> getCompoundKey(final Object key) {
+ private Map<String, Object> getCompoundKey(final Object key) {
final Set<CompoundKeyElementWrapper> elements = new TreeSet<CompoundKeyElementWrapper>();
for (Method method : key.getClass().getMethods()) {
@@ -258,8 +229,7 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
final EntityUUID uuid = new EntityUUID(containerHandler.getEntityContainerName(), entitySetName, typeRef, key);
LOG.debug("Ask for '{}({})'", typeRef.getSimpleName(), key);
- EntityTypeInvocationHandler<?> handler =
- EntityContainerFactory.getContext().entityContext().getEntity(uuid);
+ EntityTypeInvocationHandler handler = EntityContainerFactory.getContext().entityContext().getEntity(uuid);
if (handler == null) {
// not yet attached: search against the service
@@ -277,25 +247,14 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
LOG.debug("Execute query '{}'", uriBuilder.toString());
- final CommonODataEntity entity;
- final String etag;
-
- if (isSingleton) {
- final ODataRetrieveResponse<org.apache.olingo.commons.api.domain.v4.Singleton> res =
- ((ODataClient) client).getRetrieveRequestFactory().getSingletonRequest(uri).execute();
-
- entity = res.getBody();
- etag = res.getETag();
- } else {
- final ODataRetrieveResponse<CommonODataEntity> res =
- client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()).execute();
+ final ODataRetrieveResponse<CommonODataEntity> res =
+ client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()).execute();
- etag = res.getETag();
- entity = res.getBody();
+ final String etag = res.getETag();
+ final CommonODataEntity entity = res.getBody();
- if (entity == null || !key.equals(CoreUtils.getKey(client, typeRef, entity))) {
- throw new IllegalArgumentException("Invalid singleton " + typeRef.getSimpleName() + "(" + key + ")");
- }
+ if (entity == null || !key.equals(CoreUtils.getKey(client, typeRef, entity))) {
+ throw new IllegalArgumentException("Invalid singleton " + typeRef.getSimpleName() + "(" + key + ")");
}
handler = EntityTypeInvocationHandler.getInstance(entity, this, typeRef);
@@ -338,9 +297,9 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
final List<S> items = new ArrayList<S>(entities.size());
for (CommonODataEntity entity : entities) {
- final EntityTypeInvocationHandler<?> handler = EntityTypeInvocationHandler.getInstance(entity, this, typeRef);
+ final EntityTypeInvocationHandler handler = EntityTypeInvocationHandler.getInstance(entity, this, typeRef);
- final EntityTypeInvocationHandler<?> handlerInTheContext =
+ final EntityTypeInvocationHandler handlerInTheContext =
EntityContainerFactory.getContext().entityContext().getEntity(handler.getUUID());
items.add((S) Proxy.newProxyInstance(
@@ -368,8 +327,7 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
return (SEC) Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {collTypeRef},
- new EntityCollectionInvocationHandler<S, C>(
- containerHandler, items, typeRef, containerHandler.getEntityContainerName(), entitySetURI));
+ new EntityCollectionInvocationHandler<S>(containerHandler, items, typeRef, entitySetURI));
}
@Override
@@ -412,7 +370,7 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
public void delete(final KEY key) throws IllegalArgumentException {
final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
- EntityTypeInvocationHandler<?> entity = entityContext.getEntity(new EntityUUID(
+ EntityTypeInvocationHandler entity = entityContext.getEntity(new EntityUUID(
containerHandler.getEntityContainerName(),
entitySetName,
typeRef,
@@ -421,7 +379,7 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
if (entity == null) {
// search for entity
final T searched = get(key);
- entity = (EntityTypeInvocationHandler<?>) Proxy.getInvocationHandler(searched);
+ entity = (EntityTypeInvocationHandler) Proxy.getInvocationHandler(searched);
entityContext.attach(entity, AttachedEntityStatus.DELETED);
} else {
entityContext.setStatus(entity, AttachedEntityStatus.DELETED);
@@ -433,7 +391,7 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
final EntityContext entityContext = EntityContainerFactory.getContext().entityContext();
for (T en : entities) {
- final EntityTypeInvocationHandler<?> entity = (EntityTypeInvocationHandler<?>) Proxy.getInvocationHandler(en);
+ final EntityTypeInvocationHandler entity = (EntityTypeInvocationHandler) Proxy.getInvocationHandler(en);
if (entityContext.isAttached(entity)) {
entityContext.setStatus(entity, AttachedEntityStatus.DELETED);
} else {
@@ -442,7 +400,7 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
}
}
- private boolean isDeleted(final EntityTypeInvocationHandler<?> handler) {
+ private boolean isDeleted(final EntityTypeInvocationHandler handler) {
return EntityContainerFactory.getContext().entityContext().getStatus(handler) == AttachedEntityStatus.DELETED;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java
index 4054491..8a14b7e 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetIterator.java
@@ -30,13 +30,13 @@ import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
class EntitySetIterator<T extends Serializable, KEY extends Serializable, EC extends AbstractEntityCollection<T>>
implements Iterator<T> {
- private final EntitySetInvocationHandler<?, T, KEY, EC> esi;
+ private final EntitySetInvocationHandler<T, KEY, EC> esi;
private URI next;
private Iterator<T> current;
- EntitySetIterator(final URI uri, EntitySetInvocationHandler<?, T, KEY, EC> esi) {
+ EntitySetIterator(final URI uri, EntitySetInvocationHandler<T, KEY, EC> esi) {
this.esi = esi;
this.next = uri;
this.current = Collections.<T>emptyList().iterator();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityTypeInvocationHandler.java
----------------------------------------------------------------------
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/EntityTypeInvocationHandler.java
index afafeb3..884fb1c 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/EntityTypeInvocationHandler.java
@@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
@@ -46,8 +45,7 @@ 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<C extends CommonEdmEnabledODataClient<?>>
- extends AbstractTypeInvocationHandler<C> {
+public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
@@ -65,9 +63,9 @@ public class EntityTypeInvocationHandler<C extends CommonEdmEnabledODataClient<?
private EntityUUID uuid;
- static EntityTypeInvocationHandler<?> getInstance(
+ static EntityTypeInvocationHandler getInstance(
final CommonODataEntity entity,
- final EntitySetInvocationHandler<?, ?, ?, ?> entitySet,
+ final EntitySetInvocationHandler<?, ?, ?> entitySet,
final Class<?> typeRef) {
return getInstance(
@@ -77,12 +75,11 @@ public class EntityTypeInvocationHandler<C extends CommonEdmEnabledODataClient<?
entitySet.containerHandler);
}
- @SuppressWarnings({"unchecked", "rawtypes"})
- static EntityTypeInvocationHandler<?> getInstance(
+ static EntityTypeInvocationHandler getInstance(
final CommonODataEntity entity,
final String entitySetName,
final Class<?> typeRef,
- final EntityContainerInvocationHandler<?> containerHandler) {
+ final EntityContainerInvocationHandler containerHandler) {
return new EntityTypeInvocationHandler(entity, entitySetName, typeRef, containerHandler);
}
@@ -91,7 +88,7 @@ public class EntityTypeInvocationHandler<C extends CommonEdmEnabledODataClient<?
final CommonODataEntity entity,
final String entitySetName,
final Class<?> typeRef,
- final EntityContainerInvocationHandler<C> containerHandler) {
+ final EntityContainerInvocationHandler containerHandler) {
super(containerHandler.getClient(), typeRef, (ODataLinked) entity, containerHandler);
@@ -305,7 +302,7 @@ public class EntityTypeInvocationHandler<C extends CommonEdmEnabledODataClient<?
private void setStreamedProperty(final Property property, final InputStream input) {
final Object obj = propertyChanges.get(property.name());
- if (obj != null && obj instanceof InputStream) {
+ if (obj instanceof InputStream) {
IOUtils.closeQuietly((InputStream) obj);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FactoryInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FactoryInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FactoryInvocationHandler.java
index 5cfe52e..150b59d 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FactoryInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FactoryInvocationHandler.java
@@ -20,45 +20,35 @@ 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.OperationExecutor;
import org.apache.olingo.ext.proxy.api.annotations.Property;
import org.apache.olingo.ext.proxy.utils.ClassUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-class FactoryInvocationHandler<C extends CommonEdmEnabledODataClient<?>> extends AbstractInvocationHandler<C>
- implements OperationExecutor {
+class FactoryInvocationHandler extends AbstractInvocationHandler implements OperationExecutor {
private static final long serialVersionUID = 2629912294765040027L;
- /**
- * Logger.
- */
- private static final Logger LOG = LoggerFactory.getLogger(FactoryInvocationHandler.class);
+ private final EntityTypeInvocationHandler entityHandler;
- private final EntityTypeInvocationHandler<C> entityHandler;
+ private final AbstractTypeInvocationHandler invokerHandler;
- private final AbstractTypeInvocationHandler<C> invokerHandler;
+ static FactoryInvocationHandler getInstance(
+ final EntityTypeInvocationHandler entityHandler,
+ final AbstractTypeInvocationHandler targetHandler) {
- @SuppressWarnings({"rawtypes", "unchecked"})
- static FactoryInvocationHandler<?> getInstance(
- final EntityTypeInvocationHandler<?> entityHandler,
- final AbstractTypeInvocationHandler<?> targetHandler) {
return new FactoryInvocationHandler(entityHandler, targetHandler);
}
- @SuppressWarnings("unchecked")
private FactoryInvocationHandler(
- final EntityTypeInvocationHandler<C> entityHandler,
- final AbstractTypeInvocationHandler<C> targetHandler) {
+ final EntityTypeInvocationHandler entityHandler,
+ final AbstractTypeInvocationHandler targetHandler) {
+
super(targetHandler.containerHandler.getClient(), targetHandler.containerHandler);
this.invokerHandler = targetHandler;
this.entityHandler = entityHandler;
}
@Override
- @SuppressWarnings("unchecked")
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
if (isSelfMethod(method, args)) {
return invokeSelfMethod(method, args);
@@ -70,15 +60,12 @@ class FactoryInvocationHandler<C extends CommonEdmEnabledODataClient<?>> extends
throw new UnsupportedOperationException("Unsupported method " + method.getName());
}
- final ComplexTypeInvocationHandler<?> complexTypeHandler =
- ComplexTypeInvocationHandler.getInstance(client, property.name(), method.getReturnType(), entityHandler);
-
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {method.getReturnType()},
- complexTypeHandler);
+ ComplexTypeInvocationHandler.getInstance(client, property.name(), method.getReturnType(), entityHandler));
} else {
- throw new UnsupportedOperationException("Method not found: " + method);
+ throw new NoSuchMethodException(method.getName());
}
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
index 2676d59..cdc0bfb 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
@@ -27,12 +27,10 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataOperation;
-import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmOperation;
@@ -42,11 +40,8 @@ import org.apache.olingo.ext.proxy.api.OperationType;
import org.apache.olingo.ext.proxy.api.annotations.Operation;
import org.apache.olingo.ext.proxy.api.annotations.Parameter;
import org.apache.olingo.ext.proxy.utils.ClassUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-class OperationInvocationHandler<C extends CommonEdmEnabledODataClient<?>> extends AbstractInvocationHandler<C>
- implements OperationExecutor {
+class OperationInvocationHandler extends AbstractInvocationHandler implements OperationExecutor {
private static final long serialVersionUID = 2629912294765040027L;
@@ -56,29 +51,19 @@ class OperationInvocationHandler<C extends CommonEdmEnabledODataClient<?>> exten
private final String serviceRoot;
- /**
- * Logger.
- */
- private static final Logger LOG = LoggerFactory.getLogger(OperationInvocationHandler.class);
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- static OperationInvocationHandler<?> getInstance(final EntityContainerInvocationHandler<?> containerHandler) {
+ static OperationInvocationHandler getInstance(final EntityContainerInvocationHandler containerHandler) {
return new OperationInvocationHandler(containerHandler);
}
- @SuppressWarnings({"rawtypes", "unchecked"})
- static OperationInvocationHandler<?> getInstance(final EntityTypeInvocationHandler<?> entityHandler) {
+ static OperationInvocationHandler getInstance(final EntityTypeInvocationHandler entityHandler) {
return new OperationInvocationHandler(entityHandler);
}
- @SuppressWarnings({"rawtypes", "unchecked"})
- static OperationInvocationHandler<?> getInstance(final EntityCollectionInvocationHandler<?, ?> collectionHandler) {
+ static OperationInvocationHandler getInstance(final EntityCollectionInvocationHandler<?> collectionHandler) {
return new OperationInvocationHandler(collectionHandler);
}
- @SuppressWarnings("unchecked")
- private OperationInvocationHandler(final EntityContainerInvocationHandler<C> containerHandler) {
-
+ private OperationInvocationHandler(final EntityContainerInvocationHandler containerHandler) {
super(containerHandler.getClient(), containerHandler);
this.target = containerHandler;
@@ -89,8 +74,7 @@ class OperationInvocationHandler<C extends CommonEdmEnabledODataClient<?>> exten
this.serviceRoot = containerHandler.getFactory().getServiceRoot();
}
- @SuppressWarnings("unchecked")
- private OperationInvocationHandler(final EntityTypeInvocationHandler<C> entityHandler) {
+ private OperationInvocationHandler(final EntityTypeInvocationHandler entityHandler) {
super(entityHandler.getClient(), entityHandler.containerHandler);
this.target = entityHandler;
@@ -98,8 +82,7 @@ class OperationInvocationHandler<C extends CommonEdmEnabledODataClient<?>> exten
this.serviceRoot = containerHandler.getFactory().getServiceRoot();
}
- @SuppressWarnings("unchecked")
- private OperationInvocationHandler(final EntityCollectionInvocationHandler<?, C> collectionHandler) {
+ private OperationInvocationHandler(final EntityCollectionInvocationHandler<?> collectionHandler) {
super(collectionHandler.getClient(), collectionHandler.containerHandler);
this.target = collectionHandler;
@@ -112,7 +95,6 @@ class OperationInvocationHandler<C extends CommonEdmEnabledODataClient<?>> exten
}
@Override
- @SuppressWarnings("unchecked")
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
if (isSelfMethod(method, args)) {
return invokeSelfMethod(method, args);
@@ -156,7 +138,7 @@ class OperationInvocationHandler<C extends CommonEdmEnabledODataClient<?>> exten
return invokeOperation(operation, method, parameters, edmOperation.getKey(), edmOperation.getValue());
} else {
- throw new UnsupportedOperationException("Method not found: " + method);
+ throw new NoSuchMethodException(method.getName());
}
}
}
@@ -179,7 +161,7 @@ class OperationInvocationHandler<C extends CommonEdmEnabledODataClient<?>> exten
}
private Map.Entry<URI, EdmOperation> getBoundOperation(final Operation operation, final List<String> parameterNames) {
- final CommonODataEntity entity = ((EntityTypeInvocationHandler<?>) target).getEntity();
+ final CommonODataEntity entity = ((EntityTypeInvocationHandler) target).getEntity();
ODataOperation boundOp = entity.getOperation(operation.name());
if (boundOp == null) {
@@ -228,7 +210,7 @@ class OperationInvocationHandler<C extends CommonEdmEnabledODataClient<?>> exten
}
return new AbstractMap.SimpleEntry<URI, EdmOperation>(
- URI.create(((EntityCollectionInvocationHandler<?, C>) target).getURI().toASCIIString()
+ URI.create(((EntityCollectionInvocationHandler<?>) target).getURI().toASCIIString()
+ "/" + edmOperation.getName()), edmOperation);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..4ec75eb
--- /dev/null
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SingletonInvocationHandler.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.ext.proxy.commons;
+
+import java.io.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<T>>
+ extends AbstractInvocationHandler
+ implements AbstractSingleton<T, KEY, EC> {
+
+ private static final long serialVersionUID = 2450269053734776228L;
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ static SingletonInvocationHandler getInstance(
+ final Class<?> ref, final EntityContainerInvocationHandler containerHandler) {
+
+ return new SingletonInvocationHandler(ref, containerHandler);
+ }
+
+ private final EntitySetInvocationHandler<?, ?, ?> entitySetHandler;
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ private SingletonInvocationHandler(final Class<?> ref, final EntityContainerInvocationHandler containerHandler) {
+ super(containerHandler.getClient(), containerHandler);
+ this.entitySetHandler =
+ new EntitySetInvocationHandler(ref, containerHandler, (ref.getAnnotation(Singleton.class)).name());
+ }
+
+ @Override
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+ if (isSelfMethod(method, args)) {
+ return invokeSelfMethod(method, args);
+ } else {
+ throw new NoSuchMethodException(method.getName());
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T get() {
+ return (T) this.entitySetHandler.getAll().iterator().next();
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/AttachedEntity.java
----------------------------------------------------------------------
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 a30be64..96cad42 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
@@ -22,16 +22,16 @@ import org.apache.olingo.ext.proxy.commons.EntityTypeInvocationHandler;
public class AttachedEntity {
- private final EntityTypeInvocationHandler<?> entity;
+ private final EntityTypeInvocationHandler entity;
private final AttachedEntityStatus status;
- public AttachedEntity(final EntityTypeInvocationHandler<?> entity, final AttachedEntityStatus status) {
+ public AttachedEntity(final EntityTypeInvocationHandler entity, final AttachedEntityStatus status) {
this.entity = entity;
this.status = status;
}
- public EntityTypeInvocationHandler<?> getEntity() {
+ public EntityTypeInvocationHandler getEntity() {
return entity;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityContext.java
----------------------------------------------------------------------
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 7ca1a76..ab2c9a8 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
@@ -36,16 +36,16 @@ public class EntityContext implements Iterable<AttachedEntity> {
* <br/>
* This map have to be used to search for entities by key.
*/
- private final Map<EntityUUID, EntityTypeInvocationHandler<?>> searchableEntities =
- new HashMap<EntityUUID, EntityTypeInvocationHandler<?>>();
+ private final Map<EntityUUID, EntityTypeInvocationHandler> searchableEntities =
+ new HashMap<EntityUUID, EntityTypeInvocationHandler>();
/**
* All attached entities (new entities included).
* <br/>
* Attachment order will be maintained.
*/
- private final Map<EntityTypeInvocationHandler<?>, AttachedEntityStatus> allAttachedEntities =
- new LinkedHashMap<EntityTypeInvocationHandler<?>, AttachedEntityStatus>();
+ private final Map<EntityTypeInvocationHandler, AttachedEntityStatus> allAttachedEntities =
+ new LinkedHashMap<EntityTypeInvocationHandler, AttachedEntityStatus>();
/**
* Attaches an entity with status <tt>NEW</tt>.
@@ -55,7 +55,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @see AttachedEntityStatus
* @param entity entity to be attached.
*/
- public void attachNew(final EntityTypeInvocationHandler<?> entity) {
+ public void attachNew(final EntityTypeInvocationHandler 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<AttachedEntity> {
* @see AttachedEntityStatus
* @param entity entity to be attached.
*/
- public void attach(final EntityTypeInvocationHandler<?> entity) {
+ public void attach(final EntityTypeInvocationHandler entity) {
attach(entity, AttachedEntityStatus.ATTACHED);
}
@@ -83,7 +83,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @param entity entity to be attached.
* @param status status.
*/
- public void attach(final EntityTypeInvocationHandler<?> entity, final AttachedEntityStatus status) {
+ public void attach(final EntityTypeInvocationHandler 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<AttachedEntity> {
*
* @param entity entity to be detached.
*/
- public void detach(final EntityTypeInvocationHandler<?> entity) {
+ public void detach(final EntityTypeInvocationHandler entity) {
if (searchableEntities.containsKey(entity.getUUID())) {
searchableEntities.remove(entity.getUUID());
}
@@ -123,7 +123,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @param uuid entity key.
* @return retrieved entity.
*/
- public EntityTypeInvocationHandler<?> getEntity(final EntityUUID uuid) {
+ public EntityTypeInvocationHandler getEntity(final EntityUUID uuid) {
return searchableEntities.get(uuid);
}
@@ -133,7 +133,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @param entity entity to be retrieved.
* @return attached entity status.
*/
- public AttachedEntityStatus getStatus(final EntityTypeInvocationHandler<?> entity) {
+ public AttachedEntityStatus getStatus(final EntityTypeInvocationHandler entity) {
if (!isAttached(entity)) {
throw new IllegalStateException("Entity is not in the context");
}
@@ -147,7 +147,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
* @param entity attached entity to be modified.
* @param status new status.
*/
- public void setStatus(final EntityTypeInvocationHandler<?> entity, final AttachedEntityStatus status) {
+ public void setStatus(final EntityTypeInvocationHandler 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<AttachedEntity> {
* @param entity entity.
* @return <tt>true</tt> if is attached; <tt>false</tt> otherwise.
*/
- public boolean isAttached(final EntityTypeInvocationHandler<?> entity) {
+ public boolean isAttached(final EntityTypeInvocationHandler entity) {
return allAttachedEntities.containsKey(entity)
|| (entity.getUUID().getKey() != null && searchableEntities.containsKey(entity.getUUID()));
}
@@ -190,7 +190,7 @@ public class EntityContext implements Iterable<AttachedEntity> {
@Override
public Iterator<AttachedEntity> iterator() {
final List<AttachedEntity> res = new ArrayList<AttachedEntity>();
- for (Map.Entry<EntityTypeInvocationHandler<?>, AttachedEntityStatus> attachedEntity : allAttachedEntities.
+ for (Map.Entry<EntityTypeInvocationHandler, AttachedEntityStatus> attachedEntity : allAttachedEntities.
entrySet()) {
res.add(new AttachedEntity(attachedEntity.getKey(), attachedEntity.getValue()));
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java
----------------------------------------------------------------------
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 e83b2c3..791f471 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
@@ -34,16 +34,16 @@ public class EntityLinkDesc implements Serializable {
private final String sourceName;
- private final EntityTypeInvocationHandler<?> source;
+ private final EntityTypeInvocationHandler source;
- private final Collection<EntityTypeInvocationHandler<?>> targets;
+ private final Collection<EntityTypeInvocationHandler> targets;
private final ODataLinkType type;
public EntityLinkDesc(
final String sourceName,
- final EntityTypeInvocationHandler<?> source,
- final Collection<EntityTypeInvocationHandler<?>> target,
+ final EntityTypeInvocationHandler source,
+ final Collection<EntityTypeInvocationHandler> 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 EntityTypeInvocationHandler source,
+ final EntityTypeInvocationHandler target,
final ODataLinkType type) {
this.sourceName = sourceName;
this.source = source;
- this.targets = Collections.<EntityTypeInvocationHandler<?>>singleton(target);
+ this.targets = Collections.<EntityTypeInvocationHandler>singleton(target);
this.type = type;
}
@@ -66,11 +66,11 @@ public class EntityLinkDesc implements Serializable {
return sourceName;
}
- public EntityTypeInvocationHandler<?> getSource() {
+ public EntityTypeInvocationHandler getSource() {
return source;
}
- public Collection<EntityTypeInvocationHandler<?>> getTargets() {
+ public Collection<EntityTypeInvocationHandler> getTargets() {
return targets;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java
index e8fa91b..9f35182 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
@@ -109,12 +109,12 @@ public final class CoreUtils {
oo = obj;
}
- if (oo instanceof ComplexTypeInvocationHandler<?>) {
- final Class<?> typeRef = ((ComplexTypeInvocationHandler<?>) oo).getTypeRef();
+ if (oo instanceof ComplexTypeInvocationHandler) {
+ final Class<?> typeRef = ((ComplexTypeInvocationHandler) oo).getTypeRef();
final Object complex = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {typeRef},
- (ComplexTypeInvocationHandler<?>) oo);
+ (ComplexTypeInvocationHandler) oo);
for (Method method : typeRef.getMethods()) {
final Property complexPropertyAnn = method.getAnnotation(Property.class);
@@ -325,7 +325,7 @@ public final class CoreUtils {
if (bean instanceof Proxy) {
final InvocationHandler handler = Proxy.getInvocationHandler(bean);
if (handler instanceof AbstractTypeInvocationHandler) {
- typeRef = ((ComplexTypeInvocationHandler<?>) handler).getTypeRef();
+ typeRef = ((ComplexTypeInvocationHandler) handler).getTypeRef();
} else {
throw new IllegalStateException("Invalid bean " + bean);
}
@@ -410,7 +410,7 @@ public final class CoreUtils {
final CommonEdmEnabledODataClient<?> client,
final CommonODataProperty property,
final Type typeRef,
- final EntityTypeInvocationHandler<?> entityHandler)
+ final EntityTypeInvocationHandler entityHandler)
throws InstantiationException, IllegalAccessException {
Class<?> internalRef;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/pojogen-maven-plugin/src/main/resources/singleton.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/singleton.vm b/ext/pojogen-maven-plugin/src/main/resources/singleton.vm
index ed7a966..5724c73 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/singleton.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/singleton.vm
@@ -18,7 +18,7 @@
*#
package ${package};
-import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
+import org.apache.olingo.ext.proxy.api.AbstractSingleton;
import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
import org.apache.olingo.ext.proxy.api.annotations.Singleton;
import org.apache.olingo.ext.proxy.api.annotations.CompoundKey;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/ext/pojogen-maven-plugin/src/main/resources/v40/singleton.vm
----------------------------------------------------------------------
diff --git a/ext/pojogen-maven-plugin/src/main/resources/v40/singleton.vm b/ext/pojogen-maven-plugin/src/main/resources/v40/singleton.vm
index 71cc553..2436556 100644
--- a/ext/pojogen-maven-plugin/src/main/resources/v40/singleton.vm
+++ b/ext/pojogen-maven-plugin/src/main/resources/v40/singleton.vm
@@ -26,11 +26,5 @@
#end
@Singleton(name = "$singleton.Name")
-public interface $utility.capitalize($singleton.Name) extends AbstractEntitySet<$utility.getJavaType($singleton.EntityType), $type, $utility.getJavaType($singleton.EntityType)Collection> {
-
-#foreach( $dos in $utility.getDescendantsOrSelf($utility.getEdmType($singleton)) )
- #set( $djt = $utility.getJavaType($dos) )
- #set( $sIdx = $djt.lastIndexOf('.') + 1 )
- $djt new$djt.substring($sIdx)();
-#end
-}
+public interface $utility.capitalize($singleton.Name) extends AbstractSingleton<$utility.getJavaType($singleton.EntityType), $type, $utility.getJavaType($singleton.EntityType)Collection> {
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java
index c7e2948..b1b2e75 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/ContextTestITCase.java
@@ -218,16 +218,14 @@ public class ContextTestITCase extends AbstractTestITCase {
assertNotNull(customer.getOrders());
assertEquals(3, customer.getOrders().size());
- final EntityTypeInvocationHandler<?> source =
- (EntityTypeInvocationHandler<?>) Proxy.getInvocationHandler(customer);
+ final EntityTypeInvocationHandler source = (EntityTypeInvocationHandler) Proxy.getInvocationHandler(customer);
assertTrue(entityContext.isAttached(source));
assertEquals(AttachedEntityStatus.NEW, entityContext.getStatus(source));
assertEquals(3, ((Collection) (source.getLinkChanges().entrySet().iterator().next().getValue())).size());
for (Order order : toBeLinked) {
- final EntityTypeInvocationHandler<?> target =
- (EntityTypeInvocationHandler<?>) Proxy.getInvocationHandler(order);
+ final EntityTypeInvocationHandler target = (EntityTypeInvocationHandler) Proxy.getInvocationHandler(order);
assertTrue(entityContext.isAttached(target));
assertEquals(AttachedEntityStatus.NEW, entityContext.getStatus(target));
@@ -423,7 +421,7 @@ public class ContextTestITCase extends AbstractTestITCase {
private void checkUnlink(
final String sourceName,
- final EntityTypeInvocationHandler<?> source) {
+ final EntityTypeInvocationHandler source) {
boolean found = false;
for (Map.Entry<NavigationProperty, Object> property : source.getLinkChanges().entrySet()) {
@@ -436,8 +434,8 @@ public class ContextTestITCase extends AbstractTestITCase {
private void checkLink(
final String sourceName,
- final EntityTypeInvocationHandler<?> source,
- final EntityTypeInvocationHandler<?> target,
+ final EntityTypeInvocationHandler source,
+ final EntityTypeInvocationHandler target,
final boolean isCollection) {
boolean found = false;
@@ -461,9 +459,9 @@ public class ContextTestITCase extends AbstractTestITCase {
private void checkUnidirectional(
final String sourceName,
- final EntityTypeInvocationHandler<?> source,
+ final EntityTypeInvocationHandler source,
final String targetName,
- final EntityTypeInvocationHandler<?> target,
+ final EntityTypeInvocationHandler target,
final boolean isCollection) {
checkLink(sourceName, source, target, isCollection);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java
index 7fe47ce..7ee2234 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java
@@ -41,7 +41,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
@Test
public void getEmployeesCount() {
- assertNotNull(container.getCompany().get(0).operations().getEmployeesCount());
+ assertNotNull(container.getCompany().get().operations().getEmployeesCount());
}
@Test
@@ -80,7 +80,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
@Test
public void increaseRevenue() {
- final Long result = container.getCompany().get(0).operations().increaseRevenue(12L);
+ final Long result = container.getCompany().get().operations().increaseRevenue(12L);
assertNotNull(result);
}
@@ -103,7 +103,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
resetAddress(Collections.singletonList(address), 0);
assertEquals(2, person.getPersonID(), 0);
}
-
+
@Test
public void refreshDefaultPI() {
final PaymentInstrument pi = container.getAccounts().get(101).operations().refreshDefaultPI(Calendar.getInstance());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java
index b4bdda7..d9467bc 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java
@@ -19,30 +19,27 @@
package org.apache.olingo.fit.proxy.v4;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company;
+import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyCategory;
import org.junit.Test;
public class SingletonTestITCase extends AbstractTestITCase {
@Test
public void read() {
- assertNotNull(container.getCompany().get(0));
- entityContext.detachAll();
- assertNotNull(container.getCompany().iterator().next());
- entityContext.detachAll();
- assertEquals(1, container.getCompany().count(), 0);
- entityContext.detachAll();
+ final Company company = container.getCompany().get();
+ assertEquals(0, company.getCompanyID(), 0);
+ assertEquals(CompanyCategory.IT, company.getCompanyCategory());
}
@Test
public void update() {
- final Company company = container.getCompany().get(0);
+ final Company company = container.getCompany().get();
company.setRevenue(132520L);
container.flush();
- assertEquals(132520L, container.getCompany().get(0).getRevenue(), 0);
+ assertEquals(132520L, container.getCompany().get().getRevenue(), 0);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6e9fb661/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Boss.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Boss.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Boss.java
index f73247c..70c41be 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Boss.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/Boss.java
@@ -18,7 +18,7 @@
*/
package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice;
-import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
+import org.apache.olingo.ext.proxy.api.AbstractSingleton;
import org.apache.olingo.ext.proxy.api.annotations.EntitySet;
import org.apache.olingo.ext.proxy.api.annotations.Singleton;
import org.apache.olingo.ext.proxy.api.annotations.CompoundKey;
@@ -44,10 +44,5 @@ import java.util.Calendar;
@Singleton(name = "Boss")
-public interface Boss extends AbstractEntitySet<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonCollection> {
-
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person newPerson();
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer newCustomer();
- org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee newEmployee();
+public interface Boss extends AbstractSingleton<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person, Integer, org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonCollection> {
}
-