aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGert Scholten <gscholt@gmail.com>2009-11-26 10:11:26 +0100
committerShawn O. Pearce <sop@google.com>2009-12-12 19:30:19 -0800
commit8b6f1231c7fa7a291e66647c190cd943666c8e07 (patch)
tree533dfa49d48bb08d2906da40ea0dc4526655f26f
parent96d025bfaa31daeb2192ba41d9f7ce759201f864 (diff)
downloadgwtjsonrpc-8b6f1231c7fa7a291e66647c190cd943666c8e07.tar.gz
Refactor to seperate public and private API
Use .client : client/shared code .client.event : the event classes .client.impl : private api needing to be public .client.impl.ser : provided (de)serializers .client.impl.v1_1 : JSON-RPC version 1.1 impl (POST) .client.impl.v2_0 : JSON-RPC version 2.0 impl (POST+GET) Change-Id: Ic0baad30e404d2c818affb3e13c11f31fd264178 Signed-off-by: Gert Scholten <gscholt@gmail.com> Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/CallbackHandle.java1
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/JsonUtil.java15
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/RpcCompleteEvent.java37
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/RpcStartEvent.java36
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/event/BaseRpcEvent.java (renamed from src/main/java/com/google/gwtjsonrpc/client/BaseRpcEvent.java)4
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/event/RpcCompleteEvent.java73
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/event/RpcCompleteHandler.java (renamed from src/main/java/com/google/gwtjsonrpc/client/RpcCompleteHandler.java)2
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/event/RpcStartEvent.java73
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/event/RpcStartHandler.java (renamed from src/main/java/com/google/gwtjsonrpc/client/RpcStartHandler.java)2
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/AbstractJsonProxy.java (renamed from src/main/java/com/google/gwtjsonrpc/client/AbstractJsonProxy.java)6
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ArrayResultDeserializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/ArrayResultDeserializer.java)5
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/JsonCall.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JsonCall.java)27
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/JsonSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JsonSerializer.java)5
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ResultDeserializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/ResultDeserializer.java)2
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/EnumSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/EnumSerializer.java)7
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaLangString_JsonSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JavaLangString_JsonSerializer.java)4
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlDate_JsonSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JavaSqlDate_JsonSerializer.java)19
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlTimestamp_JsonSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JavaSqlTimestamp_JsonSerializer.java)32
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaUtilDate_JsonSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JavaUtilDate_JsonSerializer.java)7
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/ListSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/ListSerializer.java)4
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/ObjectArraySerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/ObjectArraySerializer.java)3
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/ObjectMapSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/ObjectMapSerializer.java)7
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/ObjectSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/ObjectSerializer.java)9
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/PrimitiveArrayResultDeserializers.java (renamed from src/main/java/com/google/gwtjsonrpc/client/PrimitiveArrayResultDeserializers.java)4
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/PrimitiveArraySerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/PrimitiveArraySerializer.java)38
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/PrimitiveResultDeserializers.java (renamed from src/main/java/com/google/gwtjsonrpc/client/PrimitiveResultDeserializers.java)4
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/SetSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/SetSerializer.java)4
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/StringMapSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/StringMapSerializer.java)9
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/ser/VoidResult_JsonSerializer.java (renamed from src/main/java/com/google/gwtjsonrpc/client/VoidResult_JsonSerializer.java)5
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/v1_1/JsonCall11HttpPost.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JsonCall11HttpPost.java)25
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/v2_0/JsonCall20.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JsonCall20.java)20
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/v2_0/JsonCall20HttpGet.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JsonCall20HttpGet.java)9
-rw-r--r--src/main/java/com/google/gwtjsonrpc/client/impl/v2_0/JsonCall20HttpPost.java (renamed from src/main/java/com/google/gwtjsonrpc/client/JsonCall20HttpPost.java)10
-rw-r--r--src/main/java/com/google/gwtjsonrpc/rebind/ProxyCreator.java12
-rw-r--r--src/main/java/com/google/gwtjsonrpc/rebind/ResultDeserializerCreator.java8
-rw-r--r--src/main/java/com/google/gwtjsonrpc/rebind/SerializerCreator.java29
36 files changed, 346 insertions, 211 deletions
diff --git a/src/main/java/com/google/gwtjsonrpc/client/CallbackHandle.java b/src/main/java/com/google/gwtjsonrpc/client/CallbackHandle.java
index 6880622..7fdd15b 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/CallbackHandle.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/CallbackHandle.java
@@ -16,6 +16,7 @@ package com.google.gwtjsonrpc.client;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
/**
* Global JavaScript function for JSON callbacks from non-RPC invocations.
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JsonUtil.java b/src/main/java/com/google/gwtjsonrpc/client/JsonUtil.java
index 2628cc4..3168a31 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JsonUtil.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/JsonUtil.java
@@ -21,6 +21,12 @@ import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.InvocationException;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
+import com.google.gwtjsonrpc.client.event.BaseRpcEvent;
+import com.google.gwtjsonrpc.client.event.RpcCompleteEvent;
+import com.google.gwtjsonrpc.client.event.RpcCompleteHandler;
+import com.google.gwtjsonrpc.client.event.RpcStartEvent;
+import com.google.gwtjsonrpc.client.event.RpcStartHandler;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
/** Shared constants between client and server implementations. */
public class JsonUtil {
@@ -31,16 +37,16 @@ public class JsonUtil {
public static final String JSON_ENC = "UTF-8";
/** Request Content-Type header for JSON data. */
- static final String JSON_REQ_CT = JSON_TYPE + "; charset=utf-8";
+ public static final String JSON_REQ_CT = JSON_TYPE + "; charset=utf-8";
/** Json-rpc 2.0: Proper Content-Type header value for JSON encoded data. */
public static final String JSONRPC20_TYPE = "application/json-rpc";
/** Json-rpc 2.0: Request Content-Type header for JSON data. */
- static final String JSONRPC20_REQ_CT = JSON_TYPE + "; charset=utf-8";
+ public static final String JSONRPC20_REQ_CT = JSON_TYPE + "; charset=utf-8";
/** Json-rpc 2.0: Content types that we SHOULD accept as being valid */
- static final String JSONRPC20_ACCEPT_CTS =
+ public static final String JSONRPC20_ACCEPT_CTS =
JSON_TYPE + ",application/json,application/jsonrequest";
@@ -114,9 +120,8 @@ public class JsonUtil {
return globalHandlers.addHandler(RpcCompleteEvent.getType(), h);
}
- static void fireEvent(BaseRpcEvent<?> event) {
+ public static void fireEvent(BaseRpcEvent<?> event) {
globalHandlers.fireEvent(event);
- event.call = null;
}
public static <T> void invoke(final ResultDeserializer<T> resultDeserializer,
diff --git a/src/main/java/com/google/gwtjsonrpc/client/RpcCompleteEvent.java b/src/main/java/com/google/gwtjsonrpc/client/RpcCompleteEvent.java
deleted file mode 100644
index 9861931..0000000
--- a/src/main/java/com/google/gwtjsonrpc/client/RpcCompleteEvent.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2009 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.gwtjsonrpc.client;
-
-
-/** Event received by {@link RpcCompleteHandler} */
-public class RpcCompleteEvent extends BaseRpcEvent<RpcCompleteHandler> {
- private static final Type<RpcCompleteHandler> TYPE =
- new Type<RpcCompleteHandler>();
- static final RpcCompleteEvent e = new RpcCompleteEvent();
-
- public static Type<RpcCompleteHandler> getType() {
- return TYPE;
- }
-
- @Override
- public Type<RpcCompleteHandler> getAssociatedType() {
- return TYPE;
- }
-
- @Override
- protected void dispatch(final RpcCompleteHandler handler) {
- handler.onRpcComplete(this);
- }
-}
diff --git a/src/main/java/com/google/gwtjsonrpc/client/RpcStartEvent.java b/src/main/java/com/google/gwtjsonrpc/client/RpcStartEvent.java
deleted file mode 100644
index d89d5f5..0000000
--- a/src/main/java/com/google/gwtjsonrpc/client/RpcStartEvent.java
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2009 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.gwtjsonrpc.client;
-
-
-/** Event received by {@link RpcStartHandler} */
-public class RpcStartEvent extends BaseRpcEvent<RpcStartHandler> {
- private static final Type<RpcStartHandler> TYPE = new Type<RpcStartHandler>();
- static final RpcStartEvent e = new RpcStartEvent();
-
- public static Type<RpcStartHandler> getType() {
- return TYPE;
- }
-
- @Override
- public Type<RpcStartHandler> getAssociatedType() {
- return TYPE;
- }
-
- @Override
- protected void dispatch(final RpcStartHandler handler) {
- handler.onRpcStart(this);
- }
-}
diff --git a/src/main/java/com/google/gwtjsonrpc/client/BaseRpcEvent.java b/src/main/java/com/google/gwtjsonrpc/client/event/BaseRpcEvent.java
index a9c2a08..d0f31ce 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/BaseRpcEvent.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/event/BaseRpcEvent.java
@@ -12,11 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.event;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
+import com.google.gwtjsonrpc.client.RemoteJsonService;
+import com.google.gwtjsonrpc.client.impl.JsonCall;
/** Common event for {@link RpcStartEvent}, {@link RpcCompleteEvent}. */
public abstract class BaseRpcEvent<T extends EventHandler> extends GwtEvent<T> {
diff --git a/src/main/java/com/google/gwtjsonrpc/client/event/RpcCompleteEvent.java b/src/main/java/com/google/gwtjsonrpc/client/event/RpcCompleteEvent.java
new file mode 100644
index 0000000..fe0792d
--- /dev/null
+++ b/src/main/java/com/google/gwtjsonrpc/client/event/RpcCompleteEvent.java
@@ -0,0 +1,73 @@
+// Copyright 2009 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.gwtjsonrpc.client.event;
+
+import com.google.gwtjsonrpc.client.JsonUtil;
+import com.google.gwtjsonrpc.client.impl.JsonCall;
+
+/** Event received by {@link RpcCompleteHandler} */
+public class RpcCompleteEvent extends BaseRpcEvent<RpcCompleteHandler> {
+ private static Type<RpcCompleteHandler> TYPE = null;
+ private static RpcCompleteEvent INSTANCE = null;
+
+ /**
+ * Fires a RpcCompleteEvent.
+ * <p>
+ * For internal use only.
+ *
+ * @param eventData
+ */
+ @SuppressWarnings("unchecked")
+ public static void fire(Object eventData) {
+ assert eventData instanceof JsonCall : "For internal use only";
+ if (TYPE != null) { // If we have a TYPE, we have an INSTANCE.
+ INSTANCE.call = (JsonCall) eventData;
+ JsonUtil.fireEvent(INSTANCE);
+ }
+ }
+
+ /**
+ * Gets the type associated with this event.
+ *
+ * @return returns the event type
+ */
+ public static Type<RpcCompleteHandler> getType() {
+ if (TYPE == null) {
+ TYPE = new Type<RpcCompleteHandler>();
+ INSTANCE = new RpcCompleteEvent();
+ }
+ return TYPE;
+ }
+
+ private RpcCompleteEvent() {
+ // Do nothing
+ }
+
+ @Override
+ public Type<RpcCompleteHandler> getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(final RpcCompleteHandler handler) {
+ handler.onRpcComplete(this);
+ }
+
+ @Override
+ protected void kill() {
+ super.kill();
+ call = null;
+ }
+}
diff --git a/src/main/java/com/google/gwtjsonrpc/client/RpcCompleteHandler.java b/src/main/java/com/google/gwtjsonrpc/client/event/RpcCompleteHandler.java
index 1265cde..d1f0045 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/RpcCompleteHandler.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/event/RpcCompleteHandler.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.event;
import com.google.gwt.event.shared.EventHandler;
diff --git a/src/main/java/com/google/gwtjsonrpc/client/event/RpcStartEvent.java b/src/main/java/com/google/gwtjsonrpc/client/event/RpcStartEvent.java
new file mode 100644
index 0000000..a24ef37
--- /dev/null
+++ b/src/main/java/com/google/gwtjsonrpc/client/event/RpcStartEvent.java
@@ -0,0 +1,73 @@
+// Copyright 2009 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.gwtjsonrpc.client.event;
+
+import com.google.gwtjsonrpc.client.JsonUtil;
+import com.google.gwtjsonrpc.client.impl.JsonCall;
+
+/** Event received by {@link RpcStartHandler} */
+public class RpcStartEvent extends BaseRpcEvent<RpcStartHandler> {
+ private static Type<RpcStartHandler> TYPE;
+ private static RpcStartEvent INSTANCE;
+
+ /**
+ * Fires a RpcStartEvent.
+ * <p>
+ * For internal use only.
+ *
+ * @param eventData
+ */
+ @SuppressWarnings("unchecked")
+ public static void fire(Object eventData) {
+ assert eventData instanceof JsonCall : "For internal use only";
+ if (TYPE != null) { // If we have a TYPE, we have an INSTANCE.
+ INSTANCE.call = (JsonCall) eventData;
+ JsonUtil.fireEvent(INSTANCE);
+ }
+ }
+
+ /**
+ * Gets the type associated with this event.
+ *
+ * @return returns the event type
+ */
+ public static Type<RpcStartHandler> getType() {
+ if (TYPE == null) {
+ TYPE = new Type<RpcStartHandler>();
+ INSTANCE = new RpcStartEvent();
+ }
+ return TYPE;
+ }
+
+ private RpcStartEvent() {
+ // Do nothing
+ }
+
+ @Override
+ public Type<RpcStartHandler> getAssociatedType() {
+ return TYPE;
+ }
+
+ @Override
+ protected void dispatch(final RpcStartHandler handler) {
+ handler.onRpcStart(this);
+ }
+
+ @Override
+ protected void kill() {
+ super.kill();
+ call = null;
+ }
+}
diff --git a/src/main/java/com/google/gwtjsonrpc/client/RpcStartHandler.java b/src/main/java/com/google/gwtjsonrpc/client/event/RpcStartHandler.java
index 3d5ab6d..dc7f8df 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/RpcStartHandler.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/event/RpcStartHandler.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.event;
import com.google.gwt.event.shared.EventHandler;
diff --git a/src/main/java/com/google/gwtjsonrpc/client/AbstractJsonProxy.java b/src/main/java/com/google/gwtjsonrpc/client/impl/AbstractJsonProxy.java
index f92216a..9f07675 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/AbstractJsonProxy.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/AbstractJsonProxy.java
@@ -12,11 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.InvocationException;
+import com.google.gwtjsonrpc.client.JsonDefTarget;
+import com.google.gwtjsonrpc.client.JsonUtil;
+import com.google.gwtjsonrpc.client.RemoteJsonService;
+import com.google.gwtjsonrpc.client.XsrfManager;
/**
* Base class for generated {@link RemoteJsonService} implementations.
diff --git a/src/main/java/com/google/gwtjsonrpc/client/ArrayResultDeserializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ArrayResultDeserializer.java
index 55ae773..b2bcedf 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/ArrayResultDeserializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ArrayResultDeserializer.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl;
import com.google.gwt.core.client.JavaScriptObject;
@@ -21,7 +21,8 @@ import com.google.gwt.core.client.JavaScriptObject;
* object array result deserializers.
*/
public abstract class ArrayResultDeserializer {
- protected static native JavaScriptObject getResult(JavaScriptObject responseObject)
+ protected static native JavaScriptObject getResult(
+ JavaScriptObject responseObject)
/*-{
return responseObject.result;
}-*/;
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JsonCall.java b/src/main/java/com/google/gwtjsonrpc/client/impl/JsonCall.java
index fb4feed..985ed8f 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JsonCall.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/JsonCall.java
@@ -12,17 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl;
import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwtjsonrpc.client.ServerUnavailableException;
+import com.google.gwtjsonrpc.client.event.RpcCompleteEvent;
+import com.google.gwtjsonrpc.client.event.RpcStartEvent;
-abstract class JsonCall<T> implements RequestCallback {
+public abstract class JsonCall<T> implements RequestCallback {
protected static final JavaScriptObject jsonParser;
static {
@@ -64,8 +66,8 @@ abstract class JsonCall<T> implements RequestCallback {
protected final AsyncCallback<T> callback;
protected int attempts;
- JsonCall(final AbstractJsonProxy abstractJsonProxy, final String methodName,
- final String requestParams,
+ protected JsonCall(final AbstractJsonProxy abstractJsonProxy,
+ final String methodName, final String requestParams,
final ResultDeserializer<T> resultDeserializer,
final AsyncCallback<T> callback) {
this.proxy = abstractJsonProxy;
@@ -75,15 +77,15 @@ abstract class JsonCall<T> implements RequestCallback {
this.callback = callback;
}
- AbstractJsonProxy getProxy() {
+ public AbstractJsonProxy getProxy() {
return proxy;
}
- String getMethodName() {
+ public String getMethodName() {
return methodName;
}
- abstract void send();
+ protected abstract void send();
protected void send(RequestBuilder rb) {
try {
@@ -95,12 +97,12 @@ abstract class JsonCall<T> implements RequestCallback {
}
if (attempts == 1) {
- fireEvent(RpcStartEvent.e);
+ RpcStartEvent.fire(this);
}
}
public void onError(final Request request, final Throwable exception) {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
if (exception.getClass() == RuntimeException.class
&& exception.getMessage().contains("XmlHttpRequest.status")) {
// GWT's XMLHTTPRequest class gives us RuntimeException when the
@@ -112,9 +114,4 @@ abstract class JsonCall<T> implements RequestCallback {
callback.onFailure(exception);
}
}
-
- protected <S extends EventHandler> void fireEvent(BaseRpcEvent<S> e) {
- e.call = this;
- JsonUtil.fireEvent(e);
- }
}
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JsonSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/JsonSerializer.java
index 6539150..74ff69a 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JsonSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/JsonSerializer.java
@@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl;
+
+import com.google.gwtjsonrpc.client.impl.ser.JavaLangString_JsonSerializer;
/**
* Converter between JSON and Java object representations.
@@ -70,6 +72,7 @@ public abstract class JsonSerializer<T> {
public static final String escapeChar(final char c) {
return escapeCharImpl(String.valueOf(c));
}
+
private static final native String escapeCharImpl(String c)/*-{ return @com.google.gwt.json.client.JSONString::escapeChar(Ljava/lang/String;)(c); }-*/;
/** Return the first character of a string, or '\0' if the string is empty. */
diff --git a/src/main/java/com/google/gwtjsonrpc/client/ResultDeserializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ResultDeserializer.java
index 87b0bbc..ffdd1b4 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/ResultDeserializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ResultDeserializer.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl;
import com.google.gwt.core.client.JavaScriptObject;
diff --git a/src/main/java/com/google/gwtjsonrpc/client/EnumSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/EnumSerializer.java
index c653c32..269be3d 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/EnumSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/EnumSerializer.java
@@ -12,10 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
+
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
/** Base serializer for Enum types. */
-public abstract class EnumSerializer<T extends Enum<?>> extends JsonSerializer<T> {
+public abstract class EnumSerializer<T extends Enum<?>> extends
+ JsonSerializer<T> {
@Override
public void printJson(final StringBuilder sb, final T o) {
sb.append('"');
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JavaLangString_JsonSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaLangString_JsonSerializer.java
index 5a044ff..fa59e82 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JavaLangString_JsonSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaLangString_JsonSerializer.java
@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
/** Default serialization for a String. */
public final class JavaLangString_JsonSerializer extends
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JavaSqlDate_JsonSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlDate_JsonSerializer.java
index cb26673..83581df 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JavaSqlDate_JsonSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlDate_JsonSerializer.java
@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
import java.sql.Date;
@@ -39,13 +41,14 @@ public final class JavaSqlDate_JsonSerializer extends
sb.append('"');
}
- private static native String toString(double utcMilli) /*-{
- var d = new Date(utcMilli);
- var p2 = @com.google.gwtjsonrpc.client.JavaSqlTimestamp_JsonSerializer::padTwo(I);
- return d.getUTCFullYear() + "-" +
- p2(1 + d.getUTCMonth()) + "-" +
- p2(d.getUTCDate());
- }-*/;
+ private static native String toString(double utcMilli)
+ /*-{
+ var d = new Date(utcMilli);
+ var p2 = @com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer::padTwo(I);
+ return d.getUTCFullYear() + "-" +
+ p2(1 + d.getUTCMonth()) + "-" +
+ p2(d.getUTCDate());
+ }-*/;
@SuppressWarnings("deprecation")
protected static java.sql.Date parseDate(final String s) {
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JavaSqlTimestamp_JsonSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlTimestamp_JsonSerializer.java
index 01e6cf3..dbf95b4 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JavaSqlTimestamp_JsonSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaSqlTimestamp_JsonSerializer.java
@@ -12,16 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
import java.sql.Timestamp;
import java.util.Date;
/** Default serialization for a {@link java.sql.Timestamp}. */
public final class JavaSqlTimestamp_JsonSerializer extends
- JsonSerializer<java.sql.Timestamp> implements ResultDeserializer<java.sql.Timestamp> {
+ JsonSerializer<java.sql.Timestamp> implements
+ ResultDeserializer<java.sql.Timestamp> {
public static final JavaSqlTimestamp_JsonSerializer INSTANCE =
new JavaSqlTimestamp_JsonSerializer();
@@ -58,18 +61,19 @@ public final class JavaSqlTimestamp_JsonSerializer extends
}
}
- private static native String toString(double utcMilli) /*-{
- var d = new Date(utcMilli);
- var p2 = @com.google.gwtjsonrpc.client.JavaSqlTimestamp_JsonSerializer::padTwo(I);
- var p3 = @com.google.gwtjsonrpc.client.JavaSqlTimestamp_JsonSerializer::padThree(I);
- return d.getUTCFullYear() + "-" +
- p2(1 + d.getUTCMonth()) + "-" +
- p2(d.getUTCDate())+ " " +
- p2(d.getUTCHours()) + ":" +
- p2(d.getUTCMinutes()) + ":" +
- p2(d.getUTCSeconds()) + "." +
- p3(d.getUTCMilliseconds()) + "000000";
- }-*/;
+ private static native String toString(double utcMilli)
+ /*-{
+ var d = new Date(utcMilli);
+ var p2 = @com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer::padTwo(I);
+ var p3 = @com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer::padThree(I);
+ return d.getUTCFullYear() + "-" +
+ p2(1 + d.getUTCMonth()) + "-" +
+ p2(d.getUTCDate())+ " " +
+ p2(d.getUTCHours()) + ":" +
+ p2(d.getUTCMinutes()) + ":" +
+ p2(d.getUTCSeconds()) + "." +
+ p3(d.getUTCMilliseconds()) + "000000";
+ }-*/;
@SuppressWarnings("deprecation")
private static java.sql.Timestamp parseTimestamp(final String s) {
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JavaUtilDate_JsonSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaUtilDate_JsonSerializer.java
index da27685..370c051 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JavaUtilDate_JsonSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/JavaUtilDate_JsonSerializer.java
@@ -12,15 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
import java.util.Date;
/** Default serialization for a {@link java.util.Date}. */
public final class JavaUtilDate_JsonSerializer extends
- JsonSerializer<java.util.Date> implements ResultDeserializer<java.util.Date>{
+ JsonSerializer<java.util.Date> implements
+ ResultDeserializer<java.util.Date> {
public static final JavaUtilDate_JsonSerializer INSTANCE =
new JavaUtilDate_JsonSerializer();
diff --git a/src/main/java/com/google/gwtjsonrpc/client/ListSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/ListSerializer.java
index 61a69e5..b1de9b3 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/ListSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/ListSerializer.java
@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
import java.util.ArrayList;
diff --git a/src/main/java/com/google/gwtjsonrpc/client/ObjectArraySerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/ObjectArraySerializer.java
index 0652cba..591e764 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/ObjectArraySerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/ObjectArraySerializer.java
@@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
/**
* Default serialization for any Object[] sort of type.
diff --git a/src/main/java/com/google/gwtjsonrpc/client/ObjectMapSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/ObjectMapSerializer.java
index f18f321..6f83c28 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/ObjectMapSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/ObjectMapSerializer.java
@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
import java.util.HashMap;
import java.util.Map;
@@ -35,7 +37,8 @@ public class ObjectMapSerializer<K, V> extends
private final JsonSerializer<K> keySerializer;
private final JsonSerializer<V> valueSerializer;
- public ObjectMapSerializer(final JsonSerializer<K> k, final JsonSerializer<V> v) {
+ public ObjectMapSerializer(final JsonSerializer<K> k,
+ final JsonSerializer<V> v) {
keySerializer = k;
valueSerializer = v;
}
diff --git a/src/main/java/com/google/gwtjsonrpc/client/ObjectSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/ObjectSerializer.java
index 0c98cfc..b691939 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/ObjectSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/ObjectSerializer.java
@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
/** Base class for generated JsonSerializer implementations. */
public abstract class ObjectSerializer<T extends Object> extends
@@ -34,7 +36,6 @@ public abstract class ObjectSerializer<T extends Object> extends
return result == null ? null : fromJson(result);
}
- static native JavaScriptObject objectResult(JavaScriptObject responseObject) /*-{
- return responseObject.result;
- }-*/;
+ static native JavaScriptObject objectResult(JavaScriptObject responseObject)
+ /*-{ return responseObject.result; }-*/;
}
diff --git a/src/main/java/com/google/gwtjsonrpc/client/PrimitiveArrayResultDeserializers.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/PrimitiveArrayResultDeserializers.java
index ce22644..3bf39e2 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/PrimitiveArrayResultDeserializers.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/PrimitiveArrayResultDeserializers.java
@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.ArrayResultDeserializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
public class PrimitiveArrayResultDeserializers extends ArrayResultDeserializer {
public static ResultDeserializer<Boolean[]> BOOLEAN_INSTANCE =
diff --git a/src/main/java/com/google/gwtjsonrpc/client/PrimitiveArraySerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/PrimitiveArraySerializer.java
index 5775094..c427483 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/PrimitiveArraySerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/PrimitiveArraySerializer.java
@@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
public class PrimitiveArraySerializer {
public static final PrimitiveArraySerializer INSTANCE =
@@ -151,33 +152,26 @@ public class PrimitiveArraySerializer {
}
// DeSerialisation native getters
- private static final native boolean getBoolean(JavaScriptObject jso, int pos) /*-{
- return jso[pos];
- }-*/;
+ private static final native boolean getBoolean(JavaScriptObject jso, int pos)
+ /*-{ return jso[pos]; }-*/;
- private static final native byte getByte(JavaScriptObject jso, int pos) /*-{
- return jso[pos];
- }-*/;
+ private static final native byte getByte(JavaScriptObject jso, int pos)
+ /*-{ return jso[pos]; }-*/;
- private static final native String getString(JavaScriptObject jso, int pos) /*-{
- return jso[pos];
- }-*/;
+ private static final native String getString(JavaScriptObject jso, int pos)
+ /*-{ return jso[pos]; }-*/;
- private static final native double getDouble(JavaScriptObject jso, int pos) /*-{
- return jso[pos];
- }-*/;
+ private static final native double getDouble(JavaScriptObject jso, int pos)
+ /*-{ return jso[pos]; }-*/;
- private static final native float getFloat(JavaScriptObject jso, int pos) /*-{
- return jso[pos];
- }-*/;
+ private static final native float getFloat(JavaScriptObject jso, int pos)
+ /*-{ return jso[pos]; }-*/;
- private static final native int getInteger(JavaScriptObject jso, int pos) /*-{
- return jso[pos];
- }-*/;
+ private static final native int getInteger(JavaScriptObject jso, int pos)
+ /*-{ return jso[pos]; }-*/;
- private static final native short getShort(JavaScriptObject jso, int pos) /*-{
- return jso[pos];
- }-*/;
+ private static final native short getShort(JavaScriptObject jso, int pos)
+ /*-{ return jso[pos]; }-*/;
// DeSerialisation of boxed primitive arrays
public void fromJson(final JavaScriptObject jso, final Boolean[] r) {
diff --git a/src/main/java/com/google/gwtjsonrpc/client/PrimitiveResultDeserializers.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/PrimitiveResultDeserializers.java
index 5725d08..c0c85b5 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/PrimitiveResultDeserializers.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/PrimitiveResultDeserializers.java
@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
public class PrimitiveResultDeserializers {
static native boolean booleanResult(JavaScriptObject responseObject)
diff --git a/src/main/java/com/google/gwtjsonrpc/client/SetSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/SetSerializer.java
index d016e83..b38cbc2 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/SetSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/SetSerializer.java
@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
import java.util.HashSet;
diff --git a/src/main/java/com/google/gwtjsonrpc/client/StringMapSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/StringMapSerializer.java
index 82f497c..d89caae 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/StringMapSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/StringMapSerializer.java
@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
import java.util.HashMap;
import java.util.Map;
@@ -81,9 +83,10 @@ public class StringMapSerializer<V> extends
return result == null ? null : fromJson(result);
}
- private native void copy(Map<String, V> r, JavaScriptObject jsObject) /*-{
+ private native void copy(Map<String, V> r, JavaScriptObject jsObject)
+ /*-{
for (var key in jsObject) {
- this.@com.google.gwtjsonrpc.client.StringMapSerializer::copyOne(Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;)(r, key, jsObject[key]);
+ this.@com.google.gwtjsonrpc.client.impl.ser.StringMapSerializer::copyOne(Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;)(r, key, jsObject[key]);
}
}-*/;
diff --git a/src/main/java/com/google/gwtjsonrpc/client/VoidResult_JsonSerializer.java b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/VoidResult_JsonSerializer.java
index d0ab55b..ff8397b 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/VoidResult_JsonSerializer.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/ser/VoidResult_JsonSerializer.java
@@ -12,9 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.ser;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwtjsonrpc.client.VoidResult;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
public class VoidResult_JsonSerializer extends JsonSerializer<VoidResult>
implements ResultDeserializer<VoidResult> {
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JsonCall11HttpPost.java b/src/main/java/com/google/gwtjsonrpc/client/impl/v1_1/JsonCall11HttpPost.java
index 126d007..fedb002 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JsonCall11HttpPost.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/v1_1/JsonCall11HttpPost.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.v1_1;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.http.client.Request;
@@ -22,6 +22,13 @@ import com.google.gwt.json.client.JSONObject;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.InvocationException;
import com.google.gwt.user.client.rpc.StatusCodeException;
+import com.google.gwtjsonrpc.client.JsonUtil;
+import com.google.gwtjsonrpc.client.RemoteJsonException;
+import com.google.gwtjsonrpc.client.event.RpcCompleteEvent;
+import com.google.gwtjsonrpc.client.impl.AbstractJsonProxy;
+import com.google.gwtjsonrpc.client.impl.JsonCall;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
/** JsonCall implementation for JsonRPC version 1.1 over HTTP POST */
public class JsonCall11HttpPost<T> extends JsonCall<T> {
@@ -34,7 +41,7 @@ public class JsonCall11HttpPost<T> extends JsonCall<T> {
}
@Override
- void send() {
+ protected void send() {
final StringBuilder body = new StringBuilder();
body.append("{\"version\":\"1.1\",\"method\":\"");
body.append(methodName);
@@ -48,7 +55,7 @@ public class JsonCall11HttpPost<T> extends JsonCall<T> {
body.append("}");
final RequestBuilder rb;
- rb = new RequestBuilder(RequestBuilder.POST, proxy.url);
+ rb = new RequestBuilder(RequestBuilder.POST, proxy.getServiceEntryPoint());
rb.setHeader("Content-Type", JsonUtil.JSON_REQ_CT);
rb.setHeader("Accept", JsonUtil.JSON_TYPE);
rb.setCallback(this);
@@ -65,7 +72,7 @@ public class JsonCall11HttpPost<T> extends JsonCall<T> {
try {
r = parse(jsonParser, rsp.getText());
} catch (RuntimeException e) {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new InvocationException("Bad JSON response: " + e));
return;
}
@@ -84,11 +91,11 @@ public class JsonCall11HttpPost<T> extends JsonCall<T> {
//
send();
} else {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new InvocationException(errmsg));
}
} else {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new RemoteJsonException(errmsg, r.error().code(),
new JSONObject(r.error()).get("error")));
}
@@ -96,17 +103,17 @@ public class JsonCall11HttpPost<T> extends JsonCall<T> {
}
if (sc == Response.SC_OK) {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
JsonUtil.invoke(resultDeserializer, callback, r);
return;
}
}
if (sc == Response.SC_OK) {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new InvocationException("No JSON response"));
} else {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new StatusCodeException(sc, rsp.getStatusText()));
}
}
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JsonCall20.java b/src/main/java/com/google/gwtjsonrpc/client/impl/v2_0/JsonCall20.java
index 27028de..61b4ce4 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JsonCall20.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/v2_0/JsonCall20.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.v2_0;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.http.client.Request;
@@ -21,6 +21,12 @@ import com.google.gwt.json.client.JSONObject;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.InvocationException;
import com.google.gwt.user.client.rpc.StatusCodeException;
+import com.google.gwtjsonrpc.client.JsonUtil;
+import com.google.gwtjsonrpc.client.RemoteJsonException;
+import com.google.gwtjsonrpc.client.event.RpcCompleteEvent;
+import com.google.gwtjsonrpc.client.impl.AbstractJsonProxy;
+import com.google.gwtjsonrpc.client.impl.JsonCall;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
/** Base JsonCall implementation for JsonRPC version 2.0 */
abstract class JsonCall20<T> extends JsonCall<T> {
@@ -43,7 +49,7 @@ abstract class JsonCall20<T> extends JsonCall<T> {
try {
r = parse(jsonParser, rsp.getText());
} catch (RuntimeException e) {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new InvocationException("Bad JSON response: " + e));
return;
}
@@ -63,11 +69,11 @@ abstract class JsonCall20<T> extends JsonCall<T> {
//
send();
} else {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new InvocationException(errmsg));
}
} else {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new RemoteJsonException(errmsg, r.error().code(),
new JSONObject(r.error()).get("data")));
}
@@ -75,17 +81,17 @@ abstract class JsonCall20<T> extends JsonCall<T> {
}
if (sc == Response.SC_OK) {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
JsonUtil.invoke(resultDeserializer, callback, r);
return;
}
}
if (sc == Response.SC_OK) {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new InvocationException("No JSON response"));
} else {
- fireEvent(RpcCompleteEvent.e);
+ RpcCompleteEvent.fire(this);
callback.onFailure(new StatusCodeException(sc, rsp.getStatusText()));
}
}
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JsonCall20HttpGet.java b/src/main/java/com/google/gwtjsonrpc/client/impl/v2_0/JsonCall20HttpGet.java
index 416ff3c..2dace8c 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JsonCall20HttpGet.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/v2_0/JsonCall20HttpGet.java
@@ -12,11 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.v2_0;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwtjsonrpc.client.JsonUtil;
+import com.google.gwtjsonrpc.client.impl.AbstractJsonProxy;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
/** JsonCall implementation for JsonRPC version 2.0 over HTTP POST */
public class JsonCall20HttpGet<T> extends JsonCall20<T> {
@@ -31,9 +34,9 @@ public class JsonCall20HttpGet<T> extends JsonCall20<T> {
}
@Override
- void send() {
+ protected void send() {
requestId = ++lastRequestId;
- final StringBuilder url = new StringBuilder(proxy.url);
+ final StringBuilder url = new StringBuilder(proxy.getServiceEntryPoint());
url.append("?jsonrpc=2.0&method=").append(methodName);
url.append("&params=").append(encodedRequestParams);
url.append("&id=").append(requestId);
diff --git a/src/main/java/com/google/gwtjsonrpc/client/JsonCall20HttpPost.java b/src/main/java/com/google/gwtjsonrpc/client/impl/v2_0/JsonCall20HttpPost.java
index a875d24..d7b495e 100644
--- a/src/main/java/com/google/gwtjsonrpc/client/JsonCall20HttpPost.java
+++ b/src/main/java/com/google/gwtjsonrpc/client/impl/v2_0/JsonCall20HttpPost.java
@@ -12,10 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtjsonrpc.client;
+package com.google.gwtjsonrpc.client.impl.v2_0;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwtjsonrpc.client.JsonUtil;
+import com.google.gwtjsonrpc.client.impl.AbstractJsonProxy;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
/** JsonCall implementation for JsonRPC version 2.0 over HTTP POST */
public class JsonCall20HttpPost<T> extends JsonCall20<T> {
@@ -27,7 +31,7 @@ public class JsonCall20HttpPost<T> extends JsonCall20<T> {
}
@Override
- void send() {
+ protected void send() {
requestId = ++lastRequestId;
final StringBuilder body = new StringBuilder();
body.append("{\"jsonrpc\":\"2.0\",\"method\":\"");
@@ -43,7 +47,7 @@ public class JsonCall20HttpPost<T> extends JsonCall20<T> {
body.append("}");
final RequestBuilder rb;
- rb = new RequestBuilder(RequestBuilder.POST, proxy.url);
+ rb = new RequestBuilder(RequestBuilder.POST, proxy.getServiceEntryPoint());
rb.setHeader("Content-Type", JsonUtil.JSONRPC20_REQ_CT);
rb.setHeader("Accept", JsonUtil.JSONRPC20_ACCEPT_CTS);
rb.setCallback(this);
diff --git a/src/main/java/com/google/gwtjsonrpc/rebind/ProxyCreator.java b/src/main/java/com/google/gwtjsonrpc/rebind/ProxyCreator.java
index 0bda41f..5c0f49d 100644
--- a/src/main/java/com/google/gwtjsonrpc/rebind/ProxyCreator.java
+++ b/src/main/java/com/google/gwtjsonrpc/rebind/ProxyCreator.java
@@ -35,18 +35,18 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
-import com.google.gwtjsonrpc.client.AbstractJsonProxy;
import com.google.gwtjsonrpc.client.CallbackHandle;
import com.google.gwtjsonrpc.client.HostPageCache;
-import com.google.gwtjsonrpc.client.JsonCall11HttpPost;
-import com.google.gwtjsonrpc.client.JsonCall20HttpGet;
-import com.google.gwtjsonrpc.client.JsonCall20HttpPost;
-import com.google.gwtjsonrpc.client.JsonSerializer;
import com.google.gwtjsonrpc.client.JsonUtil;
-import com.google.gwtjsonrpc.client.ResultDeserializer;
import com.google.gwtjsonrpc.client.RpcImpl;
import com.google.gwtjsonrpc.client.RpcImpl.Transport;
import com.google.gwtjsonrpc.client.RpcImpl.Version;
+import com.google.gwtjsonrpc.client.impl.AbstractJsonProxy;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
+import com.google.gwtjsonrpc.client.impl.v1_1.JsonCall11HttpPost;
+import com.google.gwtjsonrpc.client.impl.v2_0.JsonCall20HttpGet;
+import com.google.gwtjsonrpc.client.impl.v2_0.JsonCall20HttpPost;
import java.io.PrintWriter;
import java.util.HashSet;
diff --git a/src/main/java/com/google/gwtjsonrpc/rebind/ResultDeserializerCreator.java b/src/main/java/com/google/gwtjsonrpc/rebind/ResultDeserializerCreator.java
index acb58ad..ce8c45d 100644
--- a/src/main/java/com/google/gwtjsonrpc/rebind/ResultDeserializerCreator.java
+++ b/src/main/java/com/google/gwtjsonrpc/rebind/ResultDeserializerCreator.java
@@ -23,10 +23,10 @@ import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
-import com.google.gwtjsonrpc.client.ArrayResultDeserializer;
-import com.google.gwtjsonrpc.client.PrimitiveArrayResultDeserializers;
-import com.google.gwtjsonrpc.client.PrimitiveResultDeserializers;
-import com.google.gwtjsonrpc.client.ResultDeserializer;
+import com.google.gwtjsonrpc.client.impl.ArrayResultDeserializer;
+import com.google.gwtjsonrpc.client.impl.ResultDeserializer;
+import com.google.gwtjsonrpc.client.impl.ser.PrimitiveArrayResultDeserializers;
+import com.google.gwtjsonrpc.client.impl.ser.PrimitiveResultDeserializers;
import java.io.PrintWriter;
import java.util.HashMap;
diff --git a/src/main/java/com/google/gwtjsonrpc/rebind/SerializerCreator.java b/src/main/java/com/google/gwtjsonrpc/rebind/SerializerCreator.java
index 5781994..c443645 100644
--- a/src/main/java/com/google/gwtjsonrpc/rebind/SerializerCreator.java
+++ b/src/main/java/com/google/gwtjsonrpc/rebind/SerializerCreator.java
@@ -25,19 +25,19 @@ import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
-import com.google.gwtjsonrpc.client.EnumSerializer;
-import com.google.gwtjsonrpc.client.JavaLangString_JsonSerializer;
-import com.google.gwtjsonrpc.client.JavaSqlDate_JsonSerializer;
-import com.google.gwtjsonrpc.client.JavaSqlTimestamp_JsonSerializer;
-import com.google.gwtjsonrpc.client.JavaUtilDate_JsonSerializer;
-import com.google.gwtjsonrpc.client.JsonSerializer;
-import com.google.gwtjsonrpc.client.ListSerializer;
-import com.google.gwtjsonrpc.client.ObjectArraySerializer;
-import com.google.gwtjsonrpc.client.ObjectMapSerializer;
-import com.google.gwtjsonrpc.client.ObjectSerializer;
-import com.google.gwtjsonrpc.client.PrimitiveArraySerializer;
-import com.google.gwtjsonrpc.client.SetSerializer;
-import com.google.gwtjsonrpc.client.StringMapSerializer;
+import com.google.gwtjsonrpc.client.impl.JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.EnumSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.JavaLangString_JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.JavaSqlDate_JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.JavaUtilDate_JsonSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.ListSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.ObjectArraySerializer;
+import com.google.gwtjsonrpc.client.impl.ser.ObjectMapSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.ObjectSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.PrimitiveArraySerializer;
+import com.google.gwtjsonrpc.client.impl.ser.SetSerializer;
+import com.google.gwtjsonrpc.client.impl.ser.StringMapSerializer;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -214,7 +214,8 @@ class SerializerCreator {
// To work around this, we would need to generate serializers for
// them, this can be considered a todo
throw new UnableToCompleteException();
- } else // Rank 1 arrays work fine.
+ } else
+ // Rank 1 arrays work fine.
return;
}
checkCanSerialize(logger, type.isArray().getComponentType());