diff --git a/wsexample/definition/pom.xml b/wsexample/definition/pom.xml new file mode 100644 index 00000000..b861c651 --- /dev/null +++ b/wsexample/definition/pom.xml @@ -0,0 +1,222 @@ + + + + + 4.0.0 + com.google.code.gson + wsexample + jar + 0.1 + Gson Web Service Example + An example for Writing Clients for JSON based Web-services + + + local.repo + file repository to svn + file://${basedir}/../../../mavenrepo + + + + + gson + http://google-gson.googlecode.com/svn/mavenrepo + + true + + + true + + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + scm:svn:http://google-gson.googlecode.com/svn/trunk/wsexample + scm:svn:https://google-gson.googlecode.com/svn/trunk/wsexample + http://google-gson.codegoogle.com/svn/trunk/wsexample + + + Google Code Issue Tracking + http://code.google.com/p/google-gson/issues/list + + + + + + + com.google.code.gson + gson + 1.5 + compile + + + com.google.code.gson + wsdef + 0.1 + compile + + + + junit + junit + 3.8.2 + test + + + + + wsexample + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.5.1 + + true + true + ../../eclipse-ws + file:///${basedir}/../lib/gson-formatting-styles.xml + 1.5 + + + + org.apache.maven.plugins + maven-install-plugin + 2.2 + + + + org.mortbay.jetty + maven-jetty-plugin + 6.0.1 + + 10 + + + + org.apache.maven.plugins + maven-jxr-plugin + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + verify + + jar + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + src/main/resources/javadoc-descriptor.xml + + http://java.sun.com/j2se/1.5.0/docs/api/ + + true + true + public + + + + org.apache.maven.plugins + maven-pmd-plugin + + 1.5 + + /rulesets/basic.xml + /rulesets/imports.xml + /rulesets/unusedcode.xml + /rulesets/finalizers.xml + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + config/maven_checks.xml + + + + org.codehaus.mojo + taglist-maven-plugin + + + TODO + @todo + FIXME + XXX + + + + + org.codehaus.mojo + cobertura-maven-plugin + + + clean + + clean + + + + + + org.apache.maven.plugins + maven-release-plugin + + -DenableCiProfile=true + + + + maven-assembly-plugin + 2.2-beta-2 + + src/main/resources/assembly-descriptor.xml + wsexample-${version} + target/dist + target/assembly/work + + + + + + + Inderjeet Singh + Google Inc. + + + diff --git a/wsexample/definition/src/main/java/com/google/gson/example/model/Cart.java b/wsexample/definition/src/main/java/com/google/gson/example/model/Cart.java new file mode 100644 index 00000000..50333c63 --- /dev/null +++ b/wsexample/definition/src/main/java/com/google/gson/example/model/Cart.java @@ -0,0 +1,34 @@ +// Copyright 2010 Google Inc. All Rights Reserved. + +package com.google.gson.example.model; + +import java.util.List; + +/** + * A cart that can be posted to the server + * + * @author inder + */ +public class Cart { + private final List lineItems; + private final String buyerName; + private final String creditCard; + + public Cart(List lineItems, String buyerName, String creditCard) { + this.lineItems = lineItems; + this.buyerName = buyerName; + this.creditCard = creditCard; + } + + public List getLineItems() { + return lineItems; + } + + public String getBuyerName() { + return buyerName; + } + + public String getCreditCard() { + return creditCard; + } +} diff --git a/wsexample/definition/src/main/java/com/google/gson/example/model/LineItem.java b/wsexample/definition/src/main/java/com/google/gson/example/model/LineItem.java new file mode 100644 index 00000000..1d1b02d9 --- /dev/null +++ b/wsexample/definition/src/main/java/com/google/gson/example/model/LineItem.java @@ -0,0 +1,38 @@ +// Copyright 2010 Google Inc. All Rights Reserved. + +package com.google.gson.example.model; + +/** + * A line item in a cart + * + * @author inder + */ +public class LineItem { + private final String name; + private final int quantity; + private final long priceInMicros; + private final String currencyCode; + + public LineItem(String name, int quantity, long priceInMicros, String currencyCode) { + this.name = name; + this.quantity = quantity; + this.priceInMicros = priceInMicros; + this.currencyCode = currencyCode; + } + + public String getName() { + return name; + } + + public int getQuantity() { + return quantity; + } + + public long getPriceInMicros() { + return priceInMicros; + } + + public String getCurrencyCode() { + return currencyCode; + } +} diff --git a/wsexample/definition/src/main/java/com/google/gson/example/model/Order.java b/wsexample/definition/src/main/java/com/google/gson/example/model/Order.java new file mode 100644 index 00000000..7674eb27 --- /dev/null +++ b/wsexample/definition/src/main/java/com/google/gson/example/model/Order.java @@ -0,0 +1,27 @@ +// Copyright 2010 Google Inc. All Rights Reserved. + +package com.google.gson.example.model; + +/** + * An order + * + * @author inder + */ +public class Order { + public final Cart postedCart; + public final String orderNumber; + + public Order(Cart postedCart, String orderNumber) { + this.postedCart = postedCart; + this.orderNumber = orderNumber; + } + + public Cart getPostedCart() { + return postedCart; + } + + public String getOrderNumber() { + return orderNumber; + } + +} diff --git a/wsexample/definition/src/main/java/com/google/gson/example/model/TypedKeys.java b/wsexample/definition/src/main/java/com/google/gson/example/model/TypedKeys.java new file mode 100644 index 00000000..7f6f0163 --- /dev/null +++ b/wsexample/definition/src/main/java/com/google/gson/example/model/TypedKeys.java @@ -0,0 +1,26 @@ +// Copyright 2010 Google Inc. All Rights Reserved. + +package com.google.gson.example.model; + +import com.google.gson.webservice.definition.TypedKey; + +/** + * Definition of various constants to be used for parameter names of request and response headers, + * and request and response body. + * + * @author inder + */ +public final class TypedKeys { + public static final class Request { + public static final TypedKey AUTH_TOKEN = + new TypedKey("authToken", String.class); + } + + public static final class RequestBody { + public static final TypedKey CART = new TypedKey("cart", Cart.class); + } + + public static final class ResponseBody { + public static final TypedKey ORDER = new TypedKey("order", Order.class); + } +} diff --git a/wsexample/definition/src/main/java/com/google/gson/example/service/SampleJsonService.java b/wsexample/definition/src/main/java/com/google/gson/example/service/SampleJsonService.java new file mode 100644 index 00000000..5a513f81 --- /dev/null +++ b/wsexample/definition/src/main/java/com/google/gson/example/service/SampleJsonService.java @@ -0,0 +1,23 @@ +// Copyright 2010 Google Inc. All Rights Reserved. + +package com.google.gson.example.service; +import com.google.gson.example.model.TypedKeys; +import com.google.gson.webservice.definition.CallPath; +import com.google.gson.webservice.definition.HttpMethod; +import com.google.gson.webservice.definition.WebServiceCallSpec; + +/** + * An example of a web-service definition + * + * @author inder + */ +public class SampleJsonService { + + public static final WebServiceCallSpec PLACE_ORDER = new WebServiceCallSpec.Builder( + new CallPath("/placeOrder")) + .supportsHttpMethod(HttpMethod.POST) + .addRequestParam(TypedKeys.Request.AUTH_TOKEN) + .addRequestBodyParam(TypedKeys.RequestBody.CART) + .addResponseBodyParam(TypedKeys.ResponseBody.ORDER) + .build(); +}