Revision: 9140
Author: [email protected]
Date: Fri Oct 22 15:56:41 2010
Log: Lock down the public api of com.google.gwt.requestfactory.server, in
anticipation of most of it being killed in 2.1.1
Review at http://gwt-code-reviews.appspot.com/1051801
http://code.google.com/p/google-web-toolkit/source/detail?r=9140
Deleted:
/trunk/user/src/com/google/gwt/requestfactory/server/SampleDataPopulator.java
Modified:
/trunk/user/src/com/google/gwt/requestfactory/server/DefaultSecurityProvider.java
/trunk/user/src/com/google/gwt/requestfactory/server/JsonRequestProcessor.java
/trunk/user/src/com/google/gwt/requestfactory/server/OperationRegistry.java
/trunk/user/src/com/google/gwt/requestfactory/server/ReflectionBasedOperationRegistry.java
/trunk/user/src/com/google/gwt/requestfactory/server/RequestDefinition.java
/trunk/user/src/com/google/gwt/requestfactory/server/RequestProcessingException.java
/trunk/user/src/com/google/gwt/requestfactory/server/RequestProcessor.java
/trunk/user/src/com/google/gwt/requestfactory/server/RequestProperty.java
/trunk/user/src/com/google/gwt/requestfactory/server/RequestSecurityProvider.java
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/CollectionProperty.java
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/EnumProperty.java
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/Property.java
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/TypeLibrary.java
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/SampleDataPopulator.java
Thu Oct 14 18:28:29 2010
+++ /dev/null
@@ -1,163 +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.server;
-
-import com.google.gwt.requestfactory.client.DefaultRequestTransport;
-import com.google.gwt.requestfactory.shared.impl.Constants;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-/**
- * Class to populate the datastore with sample data in a JSON file.
- */
-public class SampleDataPopulator {
-
- /**
- * Run the sample data populator.
- *
- * @param args command-line arguments
- */
- public static void main(String args[]) {
- // TODO: cleanup argument processing and error reporting.
- if (args.length < 2) {
- printHelp();
- System.exit(-1);
- }
- try {
- if (!args[0].endsWith(DefaultRequestTransport.URL)) {
- System.err.println("Please check your URL string " + args[0]
- + ", it should end with " + DefaultRequestTransport.URL + ",
exiting");
- System.exit(-1);
- }
- SampleDataPopulator populator = new SampleDataPopulator(args[0],
args[1]);
- populator.populate();
- } catch (Exception ex) {
- ex.printStackTrace();
- printHelp();
- }
- }
-
- private static void printHelp() {
- StringBuffer sb = new StringBuffer();
- sb.append("\n");
- sb.append("Requires two arguments: the URL to post the JSON data and
the path to the JSON data file.");
- System.err.println(sb.toString());
- }
-
- private final String url;
-
- private final String filePathName;
-
- SampleDataPopulator(String url, String filePathName) {
- this.url = url;
- this.filePathName = filePathName;
- }
-
- /**
- * Populate the datastore and port the resulting JSON file.
- *
- * @throws JSONException if the input contains bad JSON
- * @throws IOException if an error occurs during file I/O
- */
- public void populate() throws JSONException, IOException {
- JSONObject jsonObject =
readAsJsonObject(readFileAsString(filePathName));
- postJsonFile(jsonObject);
- }
-
- private void postJsonFile(JSONObject contentData) throws IOException,
- JSONException {
- HttpPost post = new HttpPost(url);
- JSONObject request = new JSONObject();
- request.put(Constants.OPERATION_TOKEN, "DOESNT_WORK");
- request.put(Constants.CONTENT_TOKEN, contentData);
- StringEntity reqEntity = new StringEntity(request.toString());
- post.setEntity(reqEntity);
- HttpClient client = new DefaultHttpClient();
- HttpResponse response = client.execute(post);
- HttpEntity resEntity = response.getEntity();
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- System.out.println("SUCCESS: Put " + resEntity.getContentLength()
- + " records in the datastore!");
- return;
- }
- System.err.println("POST failed: Status line " +
response.getStatusLine()
- + ", please check your URL");
- }
-
- private JSONObject readAsJsonObject(String string) throws JSONException {
- JSONObject jsonObject = new JSONObject(string);
- return jsonObject;
- }
-
- // ugly method, refactor later when cleaning up this class.
- private byte[] readFileAsBytes(String filePathName) {
- File file = new File(filePathName);
- FileInputStream fileInputStream = null;
- byte bytes[] = null;
- try {
- fileInputStream = new FileInputStream(file);
- int byteLength = (int) file.length();
- bytes = new byte[byteLength];
- int byteOffset = 0;
- while (byteOffset < byteLength) {
- int bytesReadCount = fileInputStream.read(bytes, byteOffset,
byteLength
- - byteOffset);
- if (bytesReadCount == -1) {
- return null;
- }
- byteOffset += bytesReadCount;
- }
- } catch (IOException e) {
- // Ignored.
- } finally {
- try {
- if (fileInputStream != null) {
- fileInputStream.close();
- }
- } catch (IOException e) {
- // ignored
- }
- }
- return bytes;
- }
-
- private String readFileAsString(String filePathName) {
- byte bytes[] = readFileAsBytes(filePathName);
- if (bytes != null) {
- try {
- return new String(bytes, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- // Ignored.
- }
- return null;
- }
- return null;
- }
-
-}
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/DefaultSecurityProvider.java
Fri Oct 22 12:06:16 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/DefaultSecurityProvider.java
Fri Oct 22 15:56:41 2010
@@ -22,7 +22,7 @@
* A security provider that enforces
* {...@link com.google.gwt.requestfactory.shared.Service} annotations.
*/
-public class DefaultSecurityProvider implements RequestSecurityProvider {
+class DefaultSecurityProvider implements RequestSecurityProvider {
public void checkClass(Class<?> clazz) throws SecurityException {
Service service = clazz.getAnnotation(Service.class);
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/JsonRequestProcessor.java
Fri Oct 22 12:06:16 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/JsonRequestProcessor.java
Fri Oct 22 15:56:41 2010
@@ -61,7 +61,7 @@
/**
* An implementation of RequestProcessor for JSON encoded payloads.
*/
-public class JsonRequestProcessor implements RequestProcessor<String> {
+class JsonRequestProcessor implements RequestProcessor<String> {
// TODO should we consume String, InputStream, or JSONObject?
private class DvsData {
@@ -243,7 +243,6 @@
private Map<EntityKey, EntityData> afterDvsDataMap = new
HashMap<EntityKey, EntityData>();
// TODO - document
- @SuppressWarnings("rawtypes")
public Collection<Property<?>> allProperties(
Class<? extends EntityProxy> clazz) throws IllegalArgumentException {
return getPropertiesFromRecordProxyType(clazz).values();
@@ -759,7 +758,6 @@
/**
* Returns the property fields (name => type) for a record.
*/
- @SuppressWarnings("unchecked")
public Map<String, Property<?>> getPropertiesFromRecordProxyType(
Class<? extends EntityProxy> record) throws SecurityException {
if (!EntityProxy.class.isAssignableFrom(record)) {
@@ -771,7 +769,7 @@
for (Method method : methods) {
String methodName = method.getName();
String propertyName = null;
- Property newProperty = null;
+ Property<?> newProperty = null;
if (methodName.startsWith("get")) {
propertyName = Introspector.decapitalize(methodName.substring(3));
if (propertyName.length() == 0) {
@@ -792,7 +790,7 @@
if (newProperty == null) {
continue;
}
- Property existing = properties.put(propertyName, newProperty);
+ Property<?> existing = properties.put(propertyName, newProperty);
if (existing != null && !existing.equals(newProperty)) {
throw new IllegalStateException(String.format(
"In %s, mismatched getter and setter types for property %s, "
@@ -803,8 +801,8 @@
return properties;
}
- @SuppressWarnings("unchecked")
- public Property getPropertyFromGenericType(String propertyName, Type
type) {
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public Property<?> getPropertyFromGenericType(String propertyName, Type
type) {
if (type instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) type;
Class<?> rawType = (Class<Object>) pType.getRawType();
@@ -814,7 +812,7 @@
Type leafType = typeArgs[0];
if (leafType instanceof Class) {
return new CollectionProperty(propertyName, rawType,
- (Class) leafType);
+ (Class<?>) leafType);
}
}
}
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/OperationRegistry.java
Thu Oct 14 18:28:29 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/OperationRegistry.java
Fri Oct 22 15:56:41 2010
@@ -18,7 +18,7 @@
/**
* Maps operation name to {RequestDefinition}.
*/
-public interface OperationRegistry {
+interface OperationRegistry {
/**
* Returns the {...@link RequestDefinition} associated with the given
operation.
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/ReflectionBasedOperationRegistry.java
Fri Oct 22 12:06:16 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/ReflectionBasedOperationRegistry.java
Fri Oct 22 15:56:41 2010
@@ -35,7 +35,7 @@
* reflection to a method on a class, and returns an appropriate
* {...@link com.google.gwt.requestfactory.server.RequestDefinition}.
*/
-public class ReflectionBasedOperationRegistry implements OperationRegistry
{
+class ReflectionBasedOperationRegistry implements OperationRegistry {
class ReflectiveRequestDefinition implements RequestDefinition {
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/RequestDefinition.java
Thu Oct 14 18:28:29 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/RequestDefinition.java
Fri Oct 22 15:56:41 2010
@@ -22,7 +22,7 @@
* Implemented by enums that define the mapping between request objects and
* service methods.
*/
-public interface RequestDefinition {
+interface RequestDefinition {
/**
* Returns the name of the (domain) class that contains the method to be
* invoked on the server.
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/RequestProcessingException.java
Thu Oct 14 18:28:29 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/RequestProcessingException.java
Fri Oct 22 15:56:41 2010
@@ -20,7 +20,7 @@
* an unexpected exception is caught. Includes an appropriate
* response of T to send to the client.
*/
-public class RequestProcessingException extends Exception {
+class RequestProcessingException extends Exception {
private final Object response;
/**
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/RequestProcessor.java
Thu Oct 14 18:28:29 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/RequestProcessor.java
Fri Oct 22 15:56:41 2010
@@ -21,7 +21,7 @@
* requests, and a serialized return value of the same type is returned.
* @param <T> the type of encoding used to serialize the request (e.g.
String)
*/
-public interface RequestProcessor<T> {
+interface RequestProcessor<T> {
/**
* Decodes request, invokes methods, and re-encoded resulting return
values.
*
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/RequestProperty.java
Thu Oct 14 18:28:29 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/RequestProperty.java
Fri Oct 22 15:56:41 2010
@@ -23,7 +23,7 @@
/**
* Represents one piece in a property reference sequence.
*/
-public class RequestProperty implements Iterable<RequestProperty> {
+class RequestProperty implements Iterable<RequestProperty> {
/**
* Merge two property chains.
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/server/RequestSecurityProvider.java
Thu Oct 14 18:28:29 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/server/RequestSecurityProvider.java
Fri Oct 22 15:56:41 2010
@@ -19,7 +19,7 @@
* Enforces security policy for operations and classes, as well as
permitting
* request obfuscation.
*/
-public interface RequestSecurityProvider {
+interface RequestSecurityProvider {
/**
* Throws exception if argument is not accessible via remote requests.
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/CollectionProperty.java
Wed Sep 22 07:25:43 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/CollectionProperty.java
Fri Oct 22 15:56:41 2010
@@ -18,11 +18,6 @@
import java.util.Collection;
/**
- * <p> <span style="color:red">Experimental API: This class is still under
rapid
- * development, and is very likely to be deleted. Use it at your own risk.
- * </span> </p> Defines a property of a {...@link
com.google.gwt.requestfactory.shared.EntityProxy} that contains a
- * one-to-many set of related values.
- *
* @param <C> the type of the Container, must be List or Set
* @param <E> the type of the element the container contains
*/
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/EnumProperty.java
Wed Sep 22 04:32:28 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/EnumProperty.java
Fri Oct 22 15:56:41 2010
@@ -16,11 +16,6 @@
package com.google.gwt.requestfactory.shared.impl;
/**
- * <p>
- * <span style="color:red">Experimental API: This class is still under
rapid
- * development, and is very likely to be deleted. Use it at your own risk.
- * </span>
- * </p>
* Defines a property of a {...@link
com.google.gwt.requestfactory.shared.EntityProxy}.
*
* @param <V> the type of the property's value
=======================================
--- /trunk/user/src/com/google/gwt/requestfactory/shared/impl/Property.java
Fri Oct 8 06:15:38 2010
+++ /trunk/user/src/com/google/gwt/requestfactory/shared/impl/Property.java
Fri Oct 22 15:56:41 2010
@@ -16,11 +16,6 @@
package com.google.gwt.requestfactory.shared.impl;
/**
- * <p>
- * <span style="color:red">Experimental API: This class is still under
rapid
- * development, and is very likely to be deleted. Use it at your own risk.
- * </span>
- * </p>
* Defines a property of an {...@link EntityProxy}.
*
* @param <V> the type of the property's value
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/TypeLibrary.java
Wed Sep 29 21:51:38 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/shared/impl/TypeLibrary.java
Fri Oct 22 15:56:41 2010
@@ -25,9 +25,6 @@
import java.util.Set;
/**
- * <p> <span style="color:red">Experimental API: This class is still under
rapid
- * development, and is very likely to be deleted. Use it at your own risk.
- * </span> </p>
* Utility methods for querying, encoding, and decoding typed
* payload data.
*/
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors