revised prefix for rest packages to com.google.gson.rest from com.google.gson.webservice.rest
This commit is contained in:
parent
b8d8244016
commit
b50277c9af
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.client;
|
||||
package com.google.gson.rest.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
@ -24,11 +24,11 @@ import java.util.logging.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.rest.definition.RestCallSpec;
|
||||
import com.google.gson.rest.definition.RestRequest;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
import com.google.gson.rest.definition.RestResponse;
|
||||
import com.google.gson.webservice.definition.WebServiceSystemException;
|
||||
import com.google.gson.webservice.definition.rest.RestCallSpec;
|
||||
import com.google.gson.webservice.definition.rest.RestRequest;
|
||||
import com.google.gson.webservice.definition.rest.RestResource;
|
||||
import com.google.gson.webservice.definition.rest.RestResponse;
|
||||
|
||||
/**
|
||||
* Main class used by clients to access a Gson Web service.
|
||||
@ -36,15 +36,15 @@ import com.google.gson.webservice.definition.rest.RestResponse;
|
||||
* @author inder
|
||||
*/
|
||||
public class RestClient {
|
||||
private final WebServiceConfig config;
|
||||
private final RestServerConfig config;
|
||||
private final Logger logger;
|
||||
private final Level logLevel;
|
||||
|
||||
public RestClient(WebServiceConfig serverConfig) {
|
||||
public RestClient(RestServerConfig serverConfig) {
|
||||
this(serverConfig, null);
|
||||
}
|
||||
|
||||
public RestClient(WebServiceConfig serverConfig, Level logLevel) {
|
||||
public RestClient(RestServerConfig serverConfig, Level logLevel) {
|
||||
this.config = serverConfig;
|
||||
this.logger = logLevel == null ? null : Logger.getLogger(RestClient.class.getName());
|
||||
this.logLevel = logLevel;
|
||||
@ -61,7 +61,7 @@ public class RestClient {
|
||||
|
||||
public <R extends RestResource<R>> RestResponse<R> getResponse(
|
||||
RestCallSpec callSpec, RestRequest<R> request) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
Gson gson = new GsonBuilder().setVersion(callSpec.getVersion()).create();
|
||||
return getResponse(callSpec, request, gson);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.client;
|
||||
package com.google.gson.rest.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
@ -23,11 +23,12 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.rest.definition.RestRequest;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
import com.google.gson.webservice.definition.HeaderMap;
|
||||
import com.google.gson.webservice.definition.HeaderMapSpec;
|
||||
import com.google.gson.webservice.definition.WebServiceSystemException;
|
||||
import com.google.gson.webservice.definition.rest.RestRequest;
|
||||
import com.google.gson.webservice.definition.rest.RestResource;
|
||||
import com.google.gson.wsclient.internal.utils.Streams;
|
||||
|
||||
/**
|
||||
* Class to send Web service requests on a {@link HttpURLConnection}.
|
@ -13,7 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.client;
|
||||
package com.google.gson.rest.client;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
import com.google.gson.rest.definition.RestResponse;
|
||||
import com.google.gson.rest.definition.RestResponseSpec;
|
||||
import com.google.gson.webservice.definition.ContentBodySpec;
|
||||
import com.google.gson.webservice.definition.HeaderMap;
|
||||
import com.google.gson.webservice.definition.HeaderMapSpec;
|
||||
import com.google.gson.webservice.definition.WebServiceSystemException;
|
||||
import com.google.gson.wsclient.internal.utils.ConnectionPreconditions;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@ -25,15 +35,6 @@ import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.webservice.definition.ContentBodySpec;
|
||||
import com.google.gson.webservice.definition.HeaderMap;
|
||||
import com.google.gson.webservice.definition.HeaderMapSpec;
|
||||
import com.google.gson.webservice.definition.WebServiceSystemException;
|
||||
import com.google.gson.webservice.definition.rest.RestResource;
|
||||
import com.google.gson.webservice.definition.rest.RestResponse;
|
||||
import com.google.gson.webservice.definition.rest.RestResponseSpec;
|
||||
|
||||
/**
|
||||
* Receives a response coming on an {@link HttpURLConnection}.
|
||||
*
|
||||
@ -89,7 +90,8 @@ public final class RestResponseReceiver<R extends RestResource<R>> {
|
||||
private R readResponseBody(
|
||||
HttpURLConnection conn, Type resourceType) throws IOException {
|
||||
String connContentType = conn.getContentType();
|
||||
Preconditions.checkArgument(connContentType.contains(ContentBodySpec.JSON_CONTENT_TYPE), conn);
|
||||
ConnectionPreconditions.checkArgument(
|
||||
connContentType.contains(ContentBodySpec.JSON_CONTENT_TYPE), conn);
|
||||
Reader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
R body = (R) gson.fromJson(reader, resourceType);
|
||||
return body;
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 Google Inc.
|
||||
*
|
||||
* Licensed 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 com.google.gson.rest.client;
|
||||
|
||||
/**
|
||||
* Configuration needed to access a Gson REST service.
|
||||
*
|
||||
* @author inder
|
||||
*/
|
||||
public final class RestServerConfig {
|
||||
private final String serviceBaseUrl;
|
||||
|
||||
public RestServerConfig(String serviceBaseUrl) {
|
||||
this.serviceBaseUrl = serviceBaseUrl;
|
||||
}
|
||||
|
||||
public String getServiceBaseUrl() {
|
||||
return serviceBaseUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return serviceBaseUrl;
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ import com.google.gson.webservice.definition.HeaderMapSpec;
|
||||
import com.google.gson.webservice.definition.WebServiceSystemException;
|
||||
import com.google.gson.webservice.definition.procedural.RequestBody;
|
||||
import com.google.gson.webservice.definition.procedural.WebServiceRequest;
|
||||
import com.google.gson.wsclient.internal.utils.Streams;
|
||||
|
||||
/**
|
||||
* Class to send Web service requests on a {@link HttpURLConnection}.
|
||||
|
@ -33,6 +33,7 @@ import com.google.gson.webservice.definition.procedural.ResponseBody;
|
||||
import com.google.gson.webservice.definition.procedural.ResponseBodySpec;
|
||||
import com.google.gson.webservice.definition.procedural.ResponseSpec;
|
||||
import com.google.gson.webservice.definition.procedural.WebServiceResponse;
|
||||
import com.google.gson.wsclient.internal.utils.ConnectionPreconditions;
|
||||
|
||||
/**
|
||||
* Receives a response coming on an {@link HttpURLConnection}.
|
||||
@ -91,7 +92,7 @@ public final class ResponseReceiver {
|
||||
return new ResponseBody.Builder(bodySpec).build();
|
||||
}
|
||||
String connContentType = conn.getContentType();
|
||||
Preconditions.checkArgument(connContentType.contains(bodySpec.getContentType()), conn);
|
||||
ConnectionPreconditions.checkArgument(connContentType.contains(bodySpec.getContentType()), conn);
|
||||
Reader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
ResponseBody body = gson.fromJson(reader, ResponseBody.class);
|
||||
return body;
|
||||
|
@ -20,10 +20,10 @@ package com.google.gson.webservice.client;
|
||||
*
|
||||
* @author inder
|
||||
*/
|
||||
public final class WebServiceConfig {
|
||||
public final class ServerConfig {
|
||||
private final String serviceBaseUrl;
|
||||
|
||||
public WebServiceConfig(String serviceBaseUrl) {
|
||||
public ServerConfig(String serviceBaseUrl) {
|
||||
this.serviceBaseUrl = serviceBaseUrl;
|
||||
}
|
||||
|
@ -37,15 +37,15 @@ import com.google.gson.webservice.definition.procedural.WebServiceResponse;
|
||||
* @author inder
|
||||
*/
|
||||
public class WebServiceClient {
|
||||
private final WebServiceConfig config;
|
||||
private final ServerConfig config;
|
||||
private final Logger logger;
|
||||
private final Level logLevel;
|
||||
|
||||
public WebServiceClient(WebServiceConfig serverConfig) {
|
||||
public WebServiceClient(ServerConfig serverConfig) {
|
||||
this(serverConfig, null);
|
||||
}
|
||||
|
||||
public WebServiceClient(WebServiceConfig serverConfig, Level logLevel) {
|
||||
public WebServiceClient(ServerConfig serverConfig, Level logLevel) {
|
||||
this.config = serverConfig;
|
||||
this.logger = logLevel == null ? null : Logger.getLogger(WebServiceClient.class.getName());
|
||||
this.logLevel = logLevel;
|
||||
@ -61,8 +61,9 @@ public class WebServiceClient {
|
||||
}
|
||||
|
||||
public WebServiceResponse getResponse(WebServiceCallSpec callSpec, WebServiceRequest request) {
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(ResponseBody.class,
|
||||
new ResponseBodyGsonConverter(callSpec.getResponseSpec().getBodySpec()))
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(ResponseBody.class,
|
||||
new ResponseBodyGsonConverter(callSpec.getResponseSpec().getBodySpec()))
|
||||
.create();
|
||||
return getResponse(callSpec, request, gson);
|
||||
}
|
||||
|
@ -36,10 +36,10 @@ public class WebServiceClientAsync {
|
||||
private final boolean threadPerTask;
|
||||
private final TaskExecutor executor;
|
||||
|
||||
public WebServiceClientAsync(WebServiceConfig serverConfig) {
|
||||
public WebServiceClientAsync(ServerConfig serverConfig) {
|
||||
this(serverConfig, null);
|
||||
}
|
||||
public WebServiceClientAsync(WebServiceConfig serverConfig, Level logLevel) {
|
||||
public WebServiceClientAsync(ServerConfig serverConfig, Level logLevel) {
|
||||
this(new WebServiceClient(serverConfig, logLevel));
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.client;
|
||||
package com.google.gson.wsclient.internal.utils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -23,13 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
final class Preconditions {
|
||||
|
||||
public static void checkArgument(boolean condition) {
|
||||
if (!condition) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
public final class ConnectionPreconditions {
|
||||
|
||||
public static void checkArgument(boolean condition, HttpURLConnection conn) {
|
||||
if (!condition) {
|
||||
@ -61,12 +55,6 @@ final class Preconditions {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkNotNull(Object obj) {
|
||||
if (obj == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] readInByteArray(InputStream src) {
|
||||
ByteArrayOutputStream dst = new ByteArrayOutputStream();
|
||||
try {
|
||||
@ -76,4 +64,8 @@ final class Preconditions {
|
||||
}
|
||||
return dst.toByteArray();
|
||||
}
|
||||
|
||||
private ConnectionPreconditions() {
|
||||
// prevent instantiation
|
||||
}
|
||||
}
|
@ -13,23 +13,25 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.client;
|
||||
package com.google.gson.wsclient.internal.utils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
final class Streams {
|
||||
public final class Streams {
|
||||
|
||||
static void copy(String str, OutputStream dst, boolean closeOutput) throws IOException {
|
||||
public static void copy(String str, OutputStream dst, boolean closeOutput) throws IOException {
|
||||
byte[] bytes = str.getBytes("UTF-8");
|
||||
copy(new ByteArrayInputStream(bytes), dst, true, closeOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy contents of src to dst. Exhausts src completely, and closes both streams.
|
||||
*/
|
||||
static void copy(InputStream src, OutputStream dst, boolean closeInput, boolean closeOutput) throws IOException {
|
||||
public static void copy(InputStream src, OutputStream dst, boolean closeInput,
|
||||
boolean closeOutput) throws IOException {
|
||||
try {
|
||||
final byte[] buf = new byte[2048];
|
||||
int count;
|
||||
@ -41,4 +43,8 @@ final class Streams {
|
||||
if (closeOutput) dst.close();
|
||||
}
|
||||
}
|
||||
|
||||
private Streams() {
|
||||
// Prevent instantiation
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
/**
|
||||
* An interface to indicate that an object has an Id
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import com.google.gson.webservice.definition.CallPath;
|
||||
import com.google.gson.webservice.definition.internal.utils.Preconditions;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
/**
|
||||
* The data associated with a Rest Web service call. This includes http request header parameters
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import com.google.gson.webservice.definition.CallPath;
|
||||
import com.google.gson.webservice.definition.HeaderMapSpec;
|
||||
@ -38,18 +38,25 @@ public final class RestCallSpec {
|
||||
private final HeaderMapSpec.Builder reqParamsSpecBuilder = new HeaderMapSpec.Builder();
|
||||
private final HeaderMapSpec.Builder resParamsSpecBuilder = new HeaderMapSpec.Builder();
|
||||
private final Type resourceType;
|
||||
private double version;
|
||||
|
||||
public Builder(CallPath callPath, Type resourceType) {
|
||||
this.callPath = callPath;
|
||||
supportedHttpMethods.addAll(HttpMethod.ALL_METHODS);
|
||||
this.resourceType = resourceType;
|
||||
this.version = -1D;
|
||||
}
|
||||
|
||||
public Builder disableHttpMethod(HttpMethod httpMethod) {
|
||||
supportedHttpMethods.remove(httpMethod);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Builder setVersion(double version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T> Builder addRequestParam(TypedKey<T> param) {
|
||||
reqParamsSpecBuilder.put(param.getName(), param.getClassOfT());
|
||||
return this;
|
||||
@ -69,7 +76,7 @@ public final class RestCallSpec {
|
||||
RestResponseSpec responseSpec =
|
||||
new RestResponseSpec(resParamsSpecBuilder.build(), resourceType);
|
||||
return new RestCallSpec(supportedHttpMethods, callPath,
|
||||
requestSpec, responseSpec, resourceType);
|
||||
requestSpec, responseSpec, resourceType, version);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,10 +85,11 @@ public final class RestCallSpec {
|
||||
private final RestRequestSpec requestSpec;
|
||||
private final RestResponseSpec responseSpec;
|
||||
private final Type resourceType;
|
||||
private final double version;
|
||||
|
||||
private RestCallSpec(Set<HttpMethod> supportedHttpMethods, CallPath path,
|
||||
RestRequestSpec requestSpec, RestResponseSpec responseSpec,
|
||||
Type resourceType) {
|
||||
Type resourceType, double version) {
|
||||
Preconditions.checkArgument(!supportedHttpMethods.isEmpty());
|
||||
Preconditions.checkNotNull(path);
|
||||
this.supportedHttpMethods = supportedHttpMethods;
|
||||
@ -89,6 +97,7 @@ public final class RestCallSpec {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
this.resourceType = resourceType;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public CallPath getPath() {
|
||||
@ -111,9 +120,14 @@ public final class RestCallSpec {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public double getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("path: %s, resourceType: %s, requestSpec: %s, responseSpec: %s",
|
||||
path, resourceType, requestSpec, responseSpec);
|
||||
return String.format(
|
||||
"path: %s, version: %.2f, resourceType: %s, requestSpec: %s, responseSpec: %s",
|
||||
path, version, resourceType, requestSpec, responseSpec);
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import com.google.gson.webservice.definition.HeaderMap;
|
||||
import com.google.gson.webservice.definition.HttpMethod;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
/**
|
||||
* An interface implemented by an object that is intended to be a rest resource
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -13,13 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.rest.definition.Id;
|
||||
|
||||
/**
|
||||
* Unit test for {@link Id}
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.webservice.definition.rest;
|
||||
package com.google.gson.rest.definition;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
@ -25,7 +25,7 @@ import junit.framework.TestCase;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.webservice.definition.rest.Id;
|
||||
import com.google.gson.rest.definition.Id;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link IdTypeAdapter}
|
@ -15,17 +15,13 @@
|
||||
*/
|
||||
package com.google.gson.example.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.gson.example.model.Cart;
|
||||
import com.google.gson.example.model.LineItem;
|
||||
import com.google.gson.example.model.Order;
|
||||
import com.google.gson.example.model.TypedKeys;
|
||||
import com.google.gson.example.service.SampleJsonService;
|
||||
import com.google.gson.webservice.client.ServerConfig;
|
||||
import com.google.gson.webservice.client.WebServiceClient;
|
||||
import com.google.gson.webservice.client.WebServiceConfig;
|
||||
import com.google.gson.webservice.definition.HeaderMap;
|
||||
import com.google.gson.webservice.definition.HttpMethod;
|
||||
import com.google.gson.webservice.definition.procedural.RequestBody;
|
||||
@ -33,11 +29,15 @@ import com.google.gson.webservice.definition.procedural.WebServiceCallSpec;
|
||||
import com.google.gson.webservice.definition.procedural.WebServiceRequest;
|
||||
import com.google.gson.webservice.definition.procedural.WebServiceResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ExampleClient {
|
||||
|
||||
private final WebServiceClient wsClient;
|
||||
public ExampleClient() {
|
||||
WebServiceConfig serverConfig = new WebServiceConfig("http://localhost");
|
||||
ServerConfig serverConfig = new ServerConfig("http://localhost");
|
||||
wsClient = new WebServiceClient(serverConfig, Level.INFO);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.wsf.server.rest;
|
||||
package com.google.gson.rest.server;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
@ -21,8 +21,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.gson.webservice.definition.rest.HasId;
|
||||
import com.google.gson.webservice.definition.rest.Id;
|
||||
import com.google.gson.rest.definition.HasId;
|
||||
import com.google.gson.rest.definition.Id;
|
||||
|
||||
/**
|
||||
* This class provides a type-safe map to access values associated with Ids
|
@ -13,14 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.wsf.server.rest;
|
||||
package com.google.gson.rest.server;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.webservice.definition.rest.Id;
|
||||
import com.google.gson.webservice.definition.rest.MetaData;
|
||||
import com.google.gson.webservice.definition.rest.RestResource;
|
||||
import com.google.gson.rest.definition.Id;
|
||||
import com.google.gson.rest.definition.MetaData;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
|
||||
/**
|
||||
* A map of resources to their MetaData
|
@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.wsf.server.rest;
|
||||
package com.google.gson.rest.server;
|
||||
|
||||
import com.google.gson.webservice.definition.rest.HasId;
|
||||
import com.google.gson.webservice.definition.rest.Id;
|
||||
import com.google.gson.rest.definition.HasId;
|
||||
import com.google.gson.rest.definition.Id;
|
||||
|
||||
/**
|
||||
* An interface for a repository of rest resources. Meant for abstracting the server-side
|
@ -13,12 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.wsf.server.rest;
|
||||
package com.google.gson.rest.server;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.webservice.definition.rest.Id;
|
||||
import com.google.gson.webservice.definition.rest.MetaData;
|
||||
import com.google.gson.webservice.definition.rest.RestResource;
|
||||
import com.google.gson.rest.definition.Id;
|
||||
import com.google.gson.rest.definition.MetaData;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
|
||||
/**
|
||||
* An in-memory map of rest resources
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.wsf.server.rest;
|
||||
package com.google.gson.rest.server;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@ -26,13 +26,13 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.rest.definition.RestRequest;
|
||||
import com.google.gson.rest.definition.RestRequestSpec;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
import com.google.gson.webservice.definition.HeaderMap;
|
||||
import com.google.gson.webservice.definition.HeaderMapSpec;
|
||||
import com.google.gson.webservice.definition.HttpMethod;
|
||||
import com.google.gson.webservice.definition.WebServiceSystemException;
|
||||
import com.google.gson.webservice.definition.rest.RestRequest;
|
||||
import com.google.gson.webservice.definition.rest.RestRequestSpec;
|
||||
import com.google.gson.webservice.definition.rest.RestResource;
|
||||
|
||||
/**
|
||||
* Receives and parses a request at the server side on a {@link HttpServletRequest}.
|
@ -13,14 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.wsf.server.rest;
|
||||
package com.google.gson.rest.server;
|
||||
|
||||
import com.google.gson.rest.definition.Id;
|
||||
import com.google.gson.rest.definition.RestCallSpec;
|
||||
import com.google.gson.rest.definition.RestRequest;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
import com.google.gson.rest.definition.RestResponse;
|
||||
import com.google.gson.webservice.definition.HttpMethod;
|
||||
import com.google.gson.webservice.definition.rest.Id;
|
||||
import com.google.gson.webservice.definition.rest.RestCallSpec;
|
||||
import com.google.gson.webservice.definition.rest.RestRequest;
|
||||
import com.google.gson.webservice.definition.rest.RestResource;
|
||||
import com.google.gson.webservice.definition.rest.RestResponse;
|
||||
|
||||
public abstract class RestResponseBuilder<R extends RestResource<R>> {
|
||||
protected final Repository<R> resources;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.wsf.server.rest;
|
||||
package com.google.gson.rest.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
@ -23,11 +23,11 @@ import java.util.logging.Logger;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.rest.definition.RestResource;
|
||||
import com.google.gson.rest.definition.RestResponse;
|
||||
import com.google.gson.webservice.definition.ContentBodySpec;
|
||||
import com.google.gson.webservice.definition.HeaderMap;
|
||||
import com.google.gson.webservice.definition.HeaderMapSpec;
|
||||
import com.google.gson.webservice.definition.rest.RestResource;
|
||||
import com.google.gson.webservice.definition.rest.RestResponse;
|
||||
|
||||
/**
|
||||
* Sends a JSON web service response on {@link HttpServletResponse}.
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.wsf.inject;
|
||||
package com.google.gson.wsf.inject.server.procedural;
|
||||
|
||||
import com.google.gson.webservice.definition.procedural.RequestBodySpec;
|
||||
import com.google.gson.webservice.definition.procedural.RequestSpec;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.gson.wsf.inject;
|
||||
package com.google.gson.wsf.inject.server.procedural;
|
||||
|
||||
import com.google.gson.webservice.definition.procedural.RequestSpec;
|
||||
import com.google.gson.webservice.definition.procedural.WebServiceCallSpec;
|
Loading…
Reference in New Issue
Block a user