Revision: 8589
Author: [email protected]
Date: Fri Aug 20 00:49:52 2010
Log: We were broken by both -XdisableClassMetaData and plain old web
mode. Fixed.
Review at http://gwt-code-reviews.appspot.com/787801
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=8589
Added:
/trunk/user/test/com/google/gwt/requestfactory/RequestFactorySuite.java
/trunk/user/test/com/google/gwt/valuestore/ValueStoreSuite.java
Deleted:
/trunk/user/test/com/google/gwt/requestfactory/RequestFactorySuiteDisabled.java
/trunk/user/test/com/google/gwt/valuestore/ValueStoreSuiteDisabled.java
Modified:
/trunk/user/src/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImpl.java
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordImpl.java
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordJsoImpl.java
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordSchema.java
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordToTypeMap.java
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
/trunk/user/src/com/google/gwt/requestfactory/rebind/RequestFactoryGenerator.java
/trunk/user/src/com/google/gwt/requestfactory/server/JsonRequestProcessor.java
/trunk/user/src/com/google/gwt/requestfactory/server/RequestFactoryServlet.java
/trunk/user/test/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImplTest.java
/trunk/user/test/com/google/gwt/requestfactory/client/impl/SimpleBazRecordImpl.java
/trunk/user/test/com/google/gwt/requestfactory/client/impl/SimpleFooRecordImpl.java
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/requestfactory/RequestFactorySuite.java
Fri Aug 20 00:49:52 2010
@@ -0,0 +1,36 @@
+/*
+ * Copyright 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.gwt.requestfactory;
+
+import com.google.gwt.junit.tools.GWTTestSuite;
+import
com.google.gwt.requestfactory.client.impl.DeltaValueStoreJsonImplTest;
+import com.google.gwt.requestfactory.client.impl.RecordJsoImplTest;
+
+import junit.framework.Test;
+
+/**
+ * Tests of RequestFactory that require GWT.
+ * @see com.google.gwt.valuestore.ValueStoreSuite
+ */
+public class RequestFactorySuite {
+ public static Test suite() {
+ GWTTestSuite suite = new GWTTestSuite(
+ "Test suite for requestfactory gwt code.");
+ suite.addTestSuite(RecordJsoImplTest.class);
+ suite.addTestSuite(DeltaValueStoreJsonImplTest.class);
+ return suite;
+ }
+}
=======================================
--- /dev/null
+++ /trunk/user/test/com/google/gwt/valuestore/ValueStoreSuite.java Fri Aug
20 00:49:52 2010
@@ -0,0 +1,34 @@
+/*
+ * Copyright 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.gwt.valuestore;
+
+import com.google.gwt.junit.tools.GWTTestSuite;
+import com.google.gwt.valuestore.client.RequestFactoryTest;
+
+import junit.framework.Test;
+
+/**
+ * Tests of the valuestore package that require GWT.
+ * @see com.google.gwt.requestfactory.RequestFactorySuite
+ */
+public class ValueStoreSuite {
+ public static Test suite() {
+ GWTTestSuite suite = new GWTTestSuite(
+ "Test suite for all valuestore code.");
+ suite.addTestSuite(RequestFactoryTest.class);
+ return suite;
+ }
+}
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/RequestFactorySuiteDisabled.java
Thu Aug 19 21:07:59 2010
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 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.gwt.requestfactory;
-
-import com.google.gwt.junit.tools.GWTTestSuite;
-import
com.google.gwt.requestfactory.client.impl.DeltaValueStoreJsonImplTest;
-import com.google.gwt.requestfactory.client.impl.RecordJsoImplTest;
-
-import junit.framework.Test;
-
-/**
- * Tests of RequestFactory that require GWT.
- * @see com.google.gwt.valuestore.ValueStoreSuite
- */
-public class RequestFactorySuiteDisabled {
- public static Test suite() {
- GWTTestSuite suite = new GWTTestSuite(
- "Test suite for requestfactory gwt code.");
- suite.addTestSuite(RecordJsoImplTest.class);
- suite.addTestSuite(DeltaValueStoreJsonImplTest.class);
- return suite;
- }
-}
=======================================
--- /trunk/user/test/com/google/gwt/valuestore/ValueStoreSuiteDisabled.java
Thu Aug 19 21:07:59 2010
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 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.gwt.valuestore;
-
-import com.google.gwt.junit.tools.GWTTestSuite;
-import com.google.gwt.valuestore.client.RequestFactoryTest;
-
-import junit.framework.Test;
-
-/**
- * Tests of the valuestore package that require GWT.
- * @see com.google.gwt.requestfactory.RequestFactorySuiteDisabled
- */
-public class ValueStoreSuiteDisabled {
- public static Test suite() {
- GWTTestSuite suite = new GWTTestSuite(
- "Test suite for all valuestore code.");
- suite.addTestSuite(RequestFactoryTest.class);
- return suite;
- }
-}
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImpl.java
Thu Aug 19 13:59:07 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImpl.java
Fri Aug 20 00:49:52 2010
@@ -371,7 +371,7 @@
requestData.append(",");
}
requestData.append("{\""
- + entry.getValue().getSchema().getToken().getName() + "\":");
+ + entry.getValue().getSchema().getToken() + "\":");
if (writeOperation != WriteOperation.DELETE) {
requestData.append(impl.toJson());
} else {
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordImpl.java
Tue Aug 17 09:57:01 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordImpl.java
Fri Aug 20 00:49:52 2010
@@ -65,7 +65,7 @@
public String getUniqueId() {
return jso.getId() + "-" + (isFuture ? "IS" : "NO") + "-"
- + getSchema().getToken().getName();
+ + getSchema().getToken();
}
public Integer getVersion() {
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordJsoImpl.java
Thu Aug 19 17:13:42 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordJsoImpl.java
Fri Aug 20 00:49:52 2010
@@ -314,9 +314,6 @@
}
if (value instanceof RecordImpl) {
- RequestFactoryJsonImpl requestFactory = getRequestFactory();
- RecordSchema<?> schema = ((RecordImpl)value).getSchema();
- Class<?> token = schema.getToken();
setString(property.getName(), ((RecordImpl) value).getUniqueId());
return;
}
@@ -358,9 +355,15 @@
var key = this.__key;
delete this.__key;
+ var rf = this.__rf;
+ delete this.__rf;
+ var vs = this.__vs;
+ delete this.__vs;
// TODO verify that the stringify() from json2.js works on IE
var rtn = $wnd.JSON.stringify(this);
this.__key = key;
+ this.__rf = rf;
+ this.__vs = vs;
return rtn;
}-*/;
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordSchema.java
Wed Aug 18 15:12:56 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordSchema.java
Fri Aug 20 00:49:52 2010
@@ -39,14 +39,21 @@
* @param <R> the type of the Records this schema describes
*/
public abstract class RecordSchema<R extends Record> {
+
+ private final String token;
+
private final Set<Property<?>> allProperties;
+
{
Set<Property<?>> set = new HashSet<Property<?>>();
set.add(Record.id);
set.add(Record.version);
allProperties = Collections.unmodifiableSet(set);
}
-
+
+ public RecordSchema(String token) {
+ this.token = token;
+ }
public Set<Property<?>> allProperties() {
return allProperties;
}
@@ -60,6 +67,9 @@
public abstract RecordChangedEvent<?, ?> createChangeEvent(Record record,
WriteOperation writeOperation);
- // TODO(rjrjr) rename getProxyClass
- public abstract Class<? extends Record> getToken();
-}
+ public abstract Class<? extends Record> getProxyClass();
+
+ public String getToken() {
+ return token;
+ }
+}
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordToTypeMap.java
Thu Aug 19 17:13:42 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RecordToTypeMap.java
Fri Aug 20 00:49:52 2010
@@ -27,6 +27,7 @@
* Record class to its internal "type" representation.
*/
public interface RecordToTypeMap {
+ String getClassToken(Class<?> recordClass);
<R extends Record> RecordSchema<R> getType(Class<R> recordClass);
RecordSchema<? extends Record> getType(String token);
}
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
Thu Aug 19 17:13:42 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
Fri Aug 20 00:49:52 2010
@@ -123,21 +123,11 @@
}
public Class<? extends Record> getClass(Record proxy) {
- return ((RecordImpl) proxy).getSchema().getToken();
+ return ((RecordImpl) proxy).getSchema().getProxyClass();
}
public abstract RecordSchema<?> getSchema(String token);
- public String getToken(Record record) {
- String rtn = ((RecordImpl) record).getSchema().getToken().getName()
+ "-";
- if (((RecordImpl) record).isFuture()) {
- rtn += "0-FUTURE";
- } else {
- rtn += record.getId();
- }
- return rtn;
- }
-
/**
* @param eventBus
*/
@@ -156,7 +146,7 @@
if (schema == null) {
return null;
}
- return schema.getToken();
+ return schema.getProxyClass();
}
protected Record getProxy(String token, RecordToTypeMap recordToTypeMap)
{
@@ -184,9 +174,15 @@
return schema.create(RecordJsoImpl.create(id, -1, schema));
}
- protected String getToken(Class<? extends Record> clazz,
- RecordToTypeMap recordToTypeMap) {
- return recordToTypeMap.getType(clazz).getToken().getName();
+ protected String getToken(Record record, RecordToTypeMap
recordToTypeMap) {
+ Class<? extends Record> proxyClass = ((RecordImpl)
record).getSchema().getProxyClass();
+ String rtn = recordToTypeMap.getClassToken(proxyClass) + "-";
+ if (((RecordImpl) record).isFuture()) {
+ rtn += "0-FUTURE";
+ } else {
+ rtn += record.getId();
+ }
+ return rtn;
}
ValueStoreJsonImpl getValueStore() {
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/rebind/RequestFactoryGenerator.java
Thu Aug 19 17:13:42 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/rebind/RequestFactoryGenerator.java
Fri Aug 20 00:49:52 2010
@@ -364,10 +364,18 @@
sw.println("}");
sw.println();
+ // write getToken(Record)
+ sw.println("public String getToken(Record record) {");
+ sw.indent();
+ sw.println("return getToken(record, new " + recordToTypeMapName
+ "());");
+ sw.outdent();
+ sw.println("}");
+ sw.println();
+
// write getToken(Class)
sw.println("public String getToken(Class clazz) {");
sw.indent();
- sw.println("return getToken(clazz, new " + recordToTypeMapName
+ "());");
+ sw.println("return new " + recordToTypeMapName
+ "().getClassToken(clazz);");
sw.outdent();
sw.println("}");
sw.println();
@@ -438,21 +446,19 @@
SourceWriter sw = f.createSourceWriter(generatorContext, out);
sw.println();
- sw.println("public RecordSchema<? extends Record> getType(Class token)
{");
+ sw.println("public <R extends Record> RecordSchema<R> getType(Class<R>
recordClass) {");
sw.indent();
for (JClassType publicRecordType : generatedRecordTypes) {
String qualifiedSourceName =
publicRecordType.getQualifiedSourceName();
- sw.println("if (token == " + qualifiedSourceName + ".class) {");
+ sw.println("if (recordClass == " + qualifiedSourceName + ".class)
{");
sw.indent();
- sw.println("return " + qualifiedSourceName + "Impl.SCHEMA;");
+ sw.println("return (RecordSchema<R>) " + qualifiedSourceName
+ "Impl.SCHEMA;");
sw.outdent();
sw.println("}");
}
-
sw.println(
- "throw new IllegalArgumentException(\"Unknown token \" + token
+ ");
+ "throw new IllegalArgumentException(\"Unknown recordClass \" +
recordClass);");
sw.indent();
- sw.println("\", does not match any of the TOKEN variables of a
Record\");");
sw.outdent();
sw.outdent();
sw.println("}");
@@ -468,11 +474,28 @@
sw.outdent();
sw.println("}");
}
-
sw.println("throw new IllegalArgumentException(\"Unknown string token:
\" + token);");
sw.outdent();
sw.println("}");
+ sw.println("public String getClassToken(Class<?> recordClass) {");
+ sw.indent();
+ for (JClassType publicRecordType : generatedRecordTypes) {
+ String qualifiedSourceName =
publicRecordType.getQualifiedSourceName();
+ sw.println("if (recordClass == " + qualifiedSourceName + ".class)
{");
+ sw.indent();
+ sw.println("return \"" + qualifiedSourceName + "\";");
+ sw.outdent();
+ sw.println("}");
+ }
+ sw.println(
+ "throw new IllegalArgumentException(\"Unknown recordClass \" +
recordClass);");
+ sw.indent();
+ sw.outdent();
+ sw.outdent();
+ sw.println("}");
+
+
sw.outdent();
sw.println("}");
sw.println();
@@ -819,6 +842,13 @@
sw.outdent();
sw.println("}");
+ sw.println();
+ sw.println("public MySchema() {");
+ sw.indent();
+ sw.println("super(\"" + publicRecordType.getQualifiedSourceName()
+ "\");");
+ sw.outdent();
+ sw.println("}");
+
sw.println();
sw.println("@Override");
sw.println(String.format("public %s create(RecordJsoImpl jso, boolean
isFuture) {",
@@ -840,7 +870,7 @@
sw.println("}");
sw.println();
- sw.println("public Class getToken() {");
+ sw.println("public Class getProxyClass() {");
sw.indent();
sw.println("return " + publicRecordType.getQualifiedSourceName()
+ ".class;"
+ " // special field");
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/JsonRequestProcessor.java
Thu Aug 19 17:13:42 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/JsonRequestProcessor.java
Fri Aug 20 00:49:52 2010
@@ -364,11 +364,6 @@
}
return encodePropertyValue(returnValue);
}
-
- @SuppressWarnings("unchecked")
- private Class<? extends Record> castToRecordClass(Class<?> propertyType)
{
- return (Class<? extends Record>) propertyType;
- }
/**
* Generate an ID for a new record. The default behavior is to return
null and
@@ -432,7 +427,7 @@
* configured.
*/
log.info(String.format(
- "Ingnoring exception caught initializing bean validation
framework. "
+ "Ignoring exception caught initializing bean validation
framework. "
+ "It is probably unconfigured or misconfigured. [%s] %s ",
e.getClass().getName(), e.getLocalizedMessage()));
}
@@ -781,6 +776,11 @@
relatedObjects.put(keyRef, getJsonObject(returnValue, propertyType,
propertyContext));
}
+
+ @SuppressWarnings("unchecked")
+ private Class<? extends Record> castToRecordClass(Class<?> propertyType)
{
+ return (Class<? extends Record>) propertyType;
+ }
/**
* @throws JSONException
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/RequestFactoryServlet.java
Fri Aug 13 14:38:39 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/RequestFactoryServlet.java
Fri Aug 20 00:49:52 2010
@@ -66,6 +66,7 @@
ensureConfig();
String jsonRequestString = RPCServletUtils.readContent(
request, JSON_CONTENT_TYPE, JSON_CHARSET);
+ System.err.println(jsonRequestString);
response.setStatus(HttpServletResponse.SC_OK);
PrintWriter writer = response.getWriter();
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImplTest.java
Thu Aug 19 21:07:59 2010
+++
/trunk/user/test/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImplTest.java
Fri Aug 20 00:49:52 2010
@@ -54,11 +54,18 @@
public RecordSchema<? extends Record> getType(
String recordClass) {
- if (recordClass.equals(SimpleFooRecord.class.getName())) {
+ if (recordClass.equals("simple-foo-class-token")) {
return SimpleFooRecordImpl.SCHEMA;
}
throw new IllegalArgumentException("Unknown token " + recordClass);
}
+
+ public String getClassToken(Class<?> recordClass) {
+ if (recordClass.equals(SimpleFooRecord.class)) {
+ return "simple-foo-class-token";
+ }
+ throw new IllegalArgumentException("Unknown token " + recordClass);
+ }
};
ValueStoreJsonImpl valueStore = null;
RequestFactoryJsonImpl requestFactory = null;
@@ -104,6 +111,10 @@
public String getToken(Class<? extends Record> clazz) {
throw new UnsupportedOperationException("Auto-generated method
stub");
}
+
+ public String getToken(Record proxy) {
+ throw new UnsupportedOperationException("Auto-generated method
stub");
+ }
};
// add a record
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/client/impl/SimpleBazRecordImpl.java
Fri Aug 13 10:45:41 2010
+++
/trunk/user/test/com/google/gwt/requestfactory/client/impl/SimpleBazRecordImpl.java
Fri Aug 20 00:49:52 2010
@@ -33,12 +33,17 @@
* The Schema class.
*/
public static class MySchema extends RecordSchema<SimpleBazRecordImpl> {
+
private final Set<Property<?>> allProperties;
{
Set<Property<?>> set = new HashSet<Property<?>>();
set.addAll(super.allProperties());
allProperties = Collections.unmodifiableSet(set);
}
+
+ public MySchema() {
+ super(SimpleBazRecordImpl.class.getName());
+ }
@Override
public Set<Property<?>> allProperties() {
@@ -58,7 +63,7 @@
}
@Override
- public Class<? extends Record> getToken() {
+ public Class<? extends Record> getProxyClass() {
// ignore
return null;
}
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/client/impl/SimpleFooRecordImpl.java
Wed Aug 18 13:21:16 2010
+++
/trunk/user/test/com/google/gwt/requestfactory/client/impl/SimpleFooRecordImpl.java
Fri Aug 20 00:49:52 2010
@@ -39,7 +39,9 @@
* The Schema class.
*/
public static class MySchema extends RecordSchema<SimpleFooRecordImpl> {
+
private final Set<Property<?>> allProperties;
+
{
Set<Property<?>> set = new HashSet<Property<?>>();
set.addAll(super.allProperties());
@@ -52,6 +54,9 @@
set.add(enumField);
allProperties = Collections.unmodifiableSet(set);
}
+ public MySchema() {
+ super(SimpleFooRecord.class.getName());
+ }
@Override
public Set<Property<?>> allProperties() {
@@ -71,7 +76,7 @@
}
@Override
- public Class<? extends Record> getToken() {
+ public Class<? extends Record> getProxyClass() {
return SimpleFooRecord.class; // special field
}
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors