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 3dc3719c1..39aba85ba 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 extends Collection, Serializable { +public interface AbstractEntityCollection extends Collection, Serializable { } 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 b4df7c9bf..6f221649a 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> extends Iterable, Serializable { 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 4b200b457..c2f565c36 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); 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 000000000..fb2feca66 --- /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> + extends Serializable { + + /** + * Retrieves a singleton. + * + * @return the singleton + */ + T get(); +} 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 516664db3..5181b48fa 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> implements InvocationHandler { +abstract class AbstractInvocationHandler implements InvocationHandler { private static final long serialVersionUID = 358520026931462958L; - protected final C client; + protected final CommonEdmEnabledODataClient client; - protected EntityContainerInvocationHandler containerHandler; + protected EntityContainerInvocationHandler containerHandler; protected AbstractInvocationHandler( - final C client, final EntityContainerInvocationHandler 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[] {typeCollectionRef}, - new EntityCollectionInvocationHandler(containerHandler, items, typeRef, entityContainerName, uri)); + new EntityCollectionInvocationHandler(containerHandler, items, typeRef, uri)); } protected T getEntityProxy( @@ -128,8 +127,8 @@ abstract class AbstractInvocationHandler handler = (EntityTypeInvocationHandler) 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) EntityContainerFactory.getContext().entityContext(). - getEntity(handler.getUUID()); + handler = EntityContainerFactory.getContext().entityContext().getEntity(handler.getUUID()); } return (T) Proxy.newProxyInstance( @@ -157,7 +155,7 @@ abstract class AbstractInvocationHandler parameterValues = new HashMap(); + final Map parameterValues = new LinkedHashMap(); if (!parameters.isEmpty()) { for (Map.Entry parameter : parameters.entrySet()) { 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 d9a9d85ea..4fd5a7eb2 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> - extends AbstractInvocationHandler { +public abstract class AbstractTypeInvocationHandler extends AbstractInvocationHandler { private static final long serialVersionUID = 2629912294765040037L; @@ -61,16 +60,15 @@ public abstract class AbstractTypeInvocationHandler 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 containerHandler) { + final EntityContainerInvocationHandler containerHandler) { super(client, containerHandler); this.internal = internal; @@ -79,10 +77,10 @@ public abstract class AbstractTypeInvocationHandler client, final Class typeRef, final Object internal, - final EntityTypeInvocationHandler targetHandler) { + final EntityTypeInvocationHandler targetHandler) { super(client, targetHandler == null ? null : targetHandler.containerHandler); this.internal = internal; @@ -97,7 +95,6 @@ public abstract class AbstractTypeInvocationHandler linkedHandler = (EntityTypeInvocationHandler) etih; + final EntityTypeInvocationHandler linkedHandler = (EntityTypeInvocationHandler) etih; if (!linkedHandler.getTypeRef().isAnnotationPresent(EntityType.class)) { throw new IllegalArgumentException("Invalid argument type " + linkedHandler.getTypeRef().getSimpleName()); } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexTypeInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexTypeInvocationHandler.java index fe645aeac..69de2ea47 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> - extends AbstractTypeInvocationHandler { +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 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 handler) { + final EntityTypeInvocationHandler handler) { super(client, typeRef, complex, handler); } @@ -163,7 +161,7 @@ public class ComplexTypeInvocationHandler 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 delayedUpdates, @@ -323,13 +323,13 @@ class ContainerImpl implements Container { ? ODataLinkType.ENTITY_SET_NAVIGATION : ODataLinkType.ENTITY_NAVIGATION; - final Set> toBeLinked = new HashSet>(); + final Set toBeLinked = new HashSet(); final String serviceRoot = factory.getServiceRoot(); for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION ? (Collection) property.getValue() : Collections.singleton(property.getValue())) { - final EntityTypeInvocationHandler target = + 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> keys = new ArrayList>(); + private final List keys = new ArrayList(); private final List values = new ArrayList(); - 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); } 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 e75056a29..06d03a216 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> - extends AbstractInvocationHandler implements AbstractEntityCollection { +public class EntityCollectionInvocationHandler + extends AbstractInvocationHandler implements AbstractEntityCollection { private static final long serialVersionUID = 98078202642671726L; @@ -33,14 +38,14 @@ public class EntityCollectionInvocationHandler containerHandler, - final Collection items, final Class itemRef, final String entityContainerName) { + public EntityCollectionInvocationHandler(final EntityContainerInvocationHandler containerHandler, + final Collection items, final Class itemRef) { - this(containerHandler, items, itemRef, entityContainerName, null); + this(containerHandler, items, itemRef, null); } - public EntityCollectionInvocationHandler(final EntityContainerInvocationHandler containerHandler, - final Collection items, final Class itemRef, final String entityContainerName, final URI uri) { + public EntityCollectionInvocationHandler(final EntityContainerInvocationHandler containerHandler, + final Collection items, final Class itemRef, final URI uri) { super(containerHandler.getClient(), containerHandler); @@ -69,7 +74,7 @@ public class EntityCollectionInvocationHandler[] {returnType}, OperationInvocationHandler.getInstance(this)); } else { - throw new UnsupportedOperationException("Method not found: " + method); + throw new NoSuchMethodException(method.getName()); } } 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 0b5a5befe..e6b1bfe19 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> - extends AbstractInvocationHandler { +public final class EntityContainerInvocationHandler extends AbstractInvocationHandler { private static final long serialVersionUID = 7379006755693410764L; @@ -40,16 +41,16 @@ public final class EntityContainerInvocationHandler> EntityContainerInvocationHandler 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 instance = new EntityContainerInvocationHandler(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 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()); } } } 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 209c8ea8c..bee8d128e 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, T extends Serializable, - KEY extends Serializable, EC extends AbstractEntityCollection> - extends AbstractInvocationHandler +class EntitySetInvocationHandler< + T extends Serializable, KEY extends Serializable, EC extends AbstractEntityCollection> + extends AbstractInvocationHandler implements AbstractEntitySet { private static final long serialVersionUID = 2629912294765040027L; @@ -71,53 +69,38 @@ class EntitySetInvocationHandler, T ext */ private static final Logger LOG = LoggerFactory.getLogger(EntitySetInvocationHandler.class); + private final String entitySetName; + + private final boolean isSingleton; + private final Class typeRef; private final Class 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 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); + final Type[] entitySetParams = ((ParameterizedType) ref.getGenericInterfaces()[0]).getActualTypeArguments(); - 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(); - - this.typeRef = (Class) abstractEntitySetParams[0]; - if (typeRef.getAnnotation(EntityType.class) == null) { - throw new IllegalArgumentException("Invalid entity '" + typeRef.getSimpleName() + "'"); - } - this.collTypeRef = (Class) abstractEntitySetParams[2]; + this.typeRef = (Class) entitySetParams[0]; + this.collTypeRef = (Class) entitySetParams[2]; final CommonURIBuilder uriBuilder = client.getURIBuilder(containerHandler.getFactory().getServiceRoot()); @@ -131,19 +114,19 @@ class EntitySetInvocationHandler, T ext this.uri = uriBuilder.build(); } - Class getTypeRef() { + protected Class getTypeRef() { return typeRef; } - Class getCollTypeRef() { + protected Class getCollTypeRef() { return collTypeRef; } - String getEntitySetName() { + protected String getEntitySetName() { return entitySetName; } - URI getUri() { + protected URI getURI() { return uri; } @@ -159,7 +142,7 @@ class EntitySetInvocationHandler, 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, 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, T ext return (NEC) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[] {reference}, - new EntityCollectionInvocationHandler( - containerHandler, new ArrayList(), typeRef, containerHandler.getEntityContainerName())); + new EntityCollectionInvocationHandler(containerHandler, new ArrayList(), typeRef)); } @Override public Long count() { - if (isSingleton) { - final ODataRetrieveResponse 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, T ext return result; } - private LinkedHashMap getCompoundKey(final Object key) { + private Map getCompoundKey(final Object key) { final Set elements = new TreeSet(); for (Method method : key.getClass().getMethods()) { @@ -258,8 +229,7 @@ class EntitySetInvocationHandler, 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, T ext LOG.debug("Execute query '{}'", uriBuilder.toString()); - final CommonODataEntity entity; - final String etag; + final ODataRetrieveResponse res = + client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()).execute(); - if (isSingleton) { - final ODataRetrieveResponse res = - ((ODataClient) client).getRetrieveRequestFactory().getSingletonRequest(uri).execute(); + final String etag = res.getETag(); + final CommonODataEntity entity = res.getBody(); - entity = res.getBody(); - etag = res.getETag(); - } else { - final ODataRetrieveResponse res = - client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()).execute(); - - etag = res.getETag(); - 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, T ext final List items = new ArrayList(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, T ext return (SEC) Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class[] {collTypeRef}, - new EntityCollectionInvocationHandler( - containerHandler, items, typeRef, containerHandler.getEntityContainerName(), entitySetURI)); + new EntityCollectionInvocationHandler(containerHandler, items, typeRef, entitySetURI)); } @Override @@ -412,7 +370,7 @@ class EntitySetInvocationHandler, 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, 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, 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, T ext } } - private boolean isDeleted(final EntityTypeInvocationHandler handler) { + private boolean isDeleted(final EntityTypeInvocationHandler handler) { return EntityContainerFactory.getContext().entityContext().getStatus(handler) == AttachedEntityStatus.DELETED; } 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 4054491f6..8a14b7ed8 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> implements Iterator { - private final EntitySetInvocationHandler esi; + private final EntitySetInvocationHandler esi; private URI next; private Iterator current; - EntitySetIterator(final URI uri, EntitySetInvocationHandler esi) { + EntitySetIterator(final URI uri, EntitySetInvocationHandler esi) { this.esi = esi; this.next = uri; this.current = Collections.emptyList().iterator(); 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 afafeb3e2..884fb1ca3 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> - extends AbstractTypeInvocationHandler { +public class EntityTypeInvocationHandler extends AbstractTypeInvocationHandler { private static final long serialVersionUID = 2629912294765040037L; @@ -65,9 +63,9 @@ public class 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 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 typeRef, - final EntityContainerInvocationHandler containerHandler) { + final EntityContainerInvocationHandler containerHandler) { super(containerHandler.getClient(), typeRef, (ODataLinked) entity, containerHandler); @@ -305,7 +302,7 @@ public class EntityTypeInvocationHandler> extends AbstractInvocationHandler - 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 entityHandler; + private final AbstractTypeInvocationHandler invokerHandler; - private final AbstractTypeInvocationHandler 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 entityHandler, - final AbstractTypeInvocationHandler 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> 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()); } } } 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 2676d599f..cdc0bfba2 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> extends AbstractInvocationHandler - implements OperationExecutor { +class OperationInvocationHandler extends AbstractInvocationHandler implements OperationExecutor { private static final long serialVersionUID = 2629912294765040027L; @@ -56,29 +51,19 @@ class OperationInvocationHandler> 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 containerHandler) { - + private OperationInvocationHandler(final EntityContainerInvocationHandler containerHandler) { super(containerHandler.getClient(), containerHandler); this.target = containerHandler; @@ -89,8 +74,7 @@ class OperationInvocationHandler> exten this.serviceRoot = containerHandler.getFactory().getServiceRoot(); } - @SuppressWarnings("unchecked") - private OperationInvocationHandler(final EntityTypeInvocationHandler entityHandler) { + private OperationInvocationHandler(final EntityTypeInvocationHandler entityHandler) { super(entityHandler.getClient(), entityHandler.containerHandler); this.target = entityHandler; @@ -98,8 +82,7 @@ class OperationInvocationHandler> exten this.serviceRoot = containerHandler.getFactory().getServiceRoot(); } - @SuppressWarnings("unchecked") - private OperationInvocationHandler(final EntityCollectionInvocationHandler collectionHandler) { + private OperationInvocationHandler(final EntityCollectionInvocationHandler collectionHandler) { super(collectionHandler.getClient(), collectionHandler.containerHandler); this.target = collectionHandler; @@ -112,7 +95,6 @@ class OperationInvocationHandler> 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> 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> exten } private Map.Entry getBoundOperation(final Operation operation, final List 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> exten } return new AbstractMap.SimpleEntry( - URI.create(((EntityCollectionInvocationHandler) target).getURI().toASCIIString() + URI.create(((EntityCollectionInvocationHandler) target).getURI().toASCIIString() + "/" + edmOperation.getName()), edmOperation); } } 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 000000000..4ec75eb1d --- /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> + extends AbstractInvocationHandler + implements AbstractSingleton { + + 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(); + } +} 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 a30be64af..96cad427a 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; } 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 7ca1a7660..ab2c9a899 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 { *
* This map have to be used to search for entities by key. */ - private final Map> searchableEntities = - new HashMap>(); + private final Map searchableEntities = + new HashMap(); /** * All attached entities (new entities included). *
* Attachment order will be maintained. */ - private final Map, AttachedEntityStatus> allAttachedEntities = - new LinkedHashMap, AttachedEntityStatus>(); + private final Map allAttachedEntities = + new LinkedHashMap(); /** * Attaches an entity with status NEW. @@ -55,7 +55,7 @@ public class EntityContext implements Iterable { * @see AttachedEntityStatus * @param entity entity to be attached. */ - public void attachNew(final EntityTypeInvocationHandler entity) { + public void attachNew(final 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 { * @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 { * @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 { * * @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 { * @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 { * @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 { * @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 { * @param entity entity. * @return true if is attached; false 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 { @Override public Iterator iterator() { final List res = new ArrayList(); - for (Map.Entry, AttachedEntityStatus> attachedEntity : allAttachedEntities. + for (Map.Entry attachedEntity : allAttachedEntities. entrySet()) { res.add(new AttachedEntity(attachedEntity.getKey(), attachedEntity.getValue())); } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/context/EntityLinkDesc.java index e83b2c305..791f471ac 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> targets; + private final Collection targets; private final ODataLinkType type; public EntityLinkDesc( final String sourceName, - final EntityTypeInvocationHandler source, - final Collection> target, + final EntityTypeInvocationHandler source, + final Collection target, final ODataLinkType type) { this.sourceName = sourceName; this.source = source; @@ -53,12 +53,12 @@ public class EntityLinkDesc implements Serializable { public EntityLinkDesc( final String sourceName, - final EntityTypeInvocationHandler source, - final EntityTypeInvocationHandler target, + final EntityTypeInvocationHandler source, + final EntityTypeInvocationHandler target, final ODataLinkType type) { this.sourceName = sourceName; this.source = source; - this.targets = Collections.>singleton(target); + this.targets = Collections.singleton(target); this.type = type; } @@ -66,11 +66,11 @@ public class EntityLinkDesc implements Serializable { return sourceName; } - public EntityTypeInvocationHandler getSource() { + public EntityTypeInvocationHandler getSource() { return source; } - public Collection> getTargets() { + public Collection getTargets() { return targets; } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java index e8fa91b3c..9f35182c0 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; diff --git a/ext/pojogen-maven-plugin/src/main/resources/singleton.vm b/ext/pojogen-maven-plugin/src/main/resources/singleton.vm index ed7a96622..5724c7391 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; 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 71cc55392..2436556db 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 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 c7e2948e7..b1b2e7544 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 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); 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 7fe47ce76..7ee223457 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()); 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 b4bdda7b4..d9467bc31 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); } } 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 f73247c97..70c41bec0 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 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 { } - 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 0b985c503..4ed276135 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 newCompany(); - org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PublicCompany newPublicCompany(); +public interface Company extends AbstractSingleton { } - 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 85c781848..9d5035350 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 newStoredPI(); +public interface DefaultStoredPI extends AbstractSingleton { } - 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 ff9be59d9..3aa2ddfd2 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 newLabourUnion(); +public interface LabourUnion extends AbstractSingleton { } - 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 e75abd6ef..e44d0e597 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 newCompany(); - org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PublicCompany newPublicCompany(); +public interface PublicCompany extends AbstractSingleton { } - 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 04808c42c..ddee96b70 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 newCustomer(); +public interface VipCustomer extends AbstractSingleton { } - 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 9d51dc755..e74df1e47 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,