summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-04-30 17:15:53 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-04-30 17:15:53 +0000
commitda0aff02c15c1e29b844717f4e8911e0d1e80f5b (patch)
tree00f543f3ed8fd7ca523426f96b72f9e6079dba65 /sca-java-2.x/trunk/modules/binding-rest-runtime/src/test
parent80ca73f521b9c70ebe9bfdd6b43fde09ff6b799e (diff)
Enhanced support for JAX-RS annotations allowing @Path({id}) to be mapped to an operation expecting a id paramenter. This gives basic support for get and delete operations on a given resource
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@939744 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-rest-runtime/src/test')
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java13
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java12
2 files changed, 23 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java
index f30176f70a..9ffe8fe931 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java
@@ -19,9 +19,12 @@
package services.store;
+import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import org.oasisopen.sca.annotation.Remotable;
@@ -30,11 +33,19 @@ import org.oasisopen.sca.annotation.Remotable;
public interface Catalog {
@GET
- Item[] get();
+ Item[] getItem();
+
+ @GET
+ @Path("{id}")
+ Item getItemById(@PathParam("id") String itemId);
@POST
void addItem(Item item);
@PUT
void updateItem(Item item);
+
+ @DELETE
+ @Path("{id}")
+ void deleteItem(@PathParam("id") String itemId);
}
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java
index b71bb28596..c7a9807878 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java
@@ -46,12 +46,16 @@ public class FruitsCatalogImpl implements Catalog {
catalog.put("Pear", new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55)));
}
- public Item[] get() {
+ public Item[] getItem() {
Item[] catalogArray = new Item[catalog.size()];
catalog.values().toArray(catalogArray);
return catalogArray;
}
+ public Item getItemById(String itemId) {
+ return catalog.get(itemId);
+ }
+
public void addItem(Item item) {
catalog.put(item.getName(),item);
}
@@ -61,4 +65,10 @@ public class FruitsCatalogImpl implements Catalog {
catalog.put(item.getName(), item);
}
}
+
+ public void deleteItem(String itemId) {
+ if(catalog.get(itemId) != null) {
+ catalog.remove(itemId);
+ }
+ }
}