Delete sample/expenses console. Cool demo but it requires gwt-dev, not
viable as a sample. Fixes
http://code.google.com/p/google-web-toolkit/issues/detail?id=5681
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9351 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/console/Console.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/console/Console.java
deleted file mode 100644
index 0db3125..0000000
--- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/console/Console.java
+++ /dev/null
@@ -1,84 +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.sample.dynatablerf.console;
-
-import com.google.gwt.event.shared.SimpleEventBus;
-import com.google.gwt.requestfactory.server.testing.RequestFactoryMagic;
-import com.google.gwt.requestfactory.shared.Receiver;
-import com.google.gwt.sample.dynatablerf.shared.AddressProxy;
-import com.google.gwt.sample.dynatablerf.shared.DynaTableRequestFactory;
-import com.google.gwt.sample.dynatablerf.shared.PersonProxy;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * A proof-of-concept to demonstrate how RequestFactory can be used from
- * non-client code.
- */
-public class Console {
- public static void main(String[] args) {
- String url = "http://localhost:8888/gwtRequest";
- if (args.length == 1) {
- url = args[0];
- }
- try {
- new Console(new URI(url)).exec();
- System.exit(0);
- } catch (URISyntaxException e) {
- System.err.println("Could not parse argument");
- }
- System.exit(1);
- }
-
- private final DynaTableRequestFactory rf;
-
- private Console(URI uri) {
- /*
- * Instantiation of the RequestFactory interface uses the
- * RequestFactoryMagic class instead of GWT.create().
- */
- this.rf = RequestFactoryMagic.create(DynaTableRequestFactory.class);
- // Initialization follows the same pattern as client code
- rf.initialize(new SimpleEventBus(), new HttpClientTransport(uri));
- }
-
- /**
- * Making a request from non-GWT code is similar. The implementation of the
- * demonstration HttpClientTransport issues the requests synchronously. A
- * different transport system might use asynchronous callbacks.
- */
- private void exec() {
- rf.schoolCalendarRequest().getPeople(0, 100,
- Arrays.asList(true, true, true, true, true, true, true)).with("address").fire(
- new Receiver<List<PersonProxy>>() {
- @Override
- public void onSuccess(List<PersonProxy> response) {
- // Print each record to the console
- for (PersonProxy person : response) {
- AddressProxy address = person.getAddress();
- String addressBlob = address.getStreet() + " "
- + address.getCity() + " " + address.getState() + " "
- + address.getZip();
- System.out.printf("%-40s%40s\n%80s\n\n", person.getName(),
- person.getDescription(), addressBlob);
- }
- }
- });
- }
-}
diff --git a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/console/HttpClientTransport.java b/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/console/HttpClientTransport.java
deleted file mode 100644
index cfdb2dd..0000000
--- a/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/console/HttpClientTransport.java
+++ /dev/null
@@ -1,99 +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.sample.dynatablerf.console;
-
-import com.google.gwt.requestfactory.shared.RequestTransport;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
-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 java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-/**
- * This is a simple implementation of {@link RequestTransport} that uses
- * HttpClient. It is not suitable for production use, but demonstrates the
- * minimum functionality necessary to implement a custom RequestTransport.
- */
-class HttpClientTransport implements RequestTransport {
- private final URI uri;
-
- public HttpClientTransport(URI uri) {
- this.uri = uri;
- }
-
- public void send(String payload, TransportReceiver receiver) {
- HttpClient client = new DefaultHttpClient();
- HttpPost post = new HttpPost();
- post.setHeader("Content-Type", "application/json;charset=UTF-8");
- post.setURI(uri);
- Throwable ex;
- try {
- post.setEntity(new StringEntity(payload, "UTF-8"));
- HttpResponse response = client.execute(post);
- if (200 == response.getStatusLine().getStatusCode()) {
- String contents = readStreamAsString(response.getEntity().getContent());
- receiver.onTransportSuccess(contents);
- } else {
- receiver.onTransportFailure(response.getStatusLine().getReasonPhrase());
- }
- return;
- } catch (UnsupportedEncodingException e) {
- ex = e;
- } catch (ClientProtocolException e) {
- ex = e;
- } catch (IOException e) {
- ex = e;
- }
- receiver.onTransportFailure(ex.getMessage());
- }
-
- /**
- * Reads an entire input stream as String. Closes the input stream.
- */
- private String readStreamAsString(InputStream in) {
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
- byte[] buffer = new byte[1024];
- int count;
- do {
- count = in.read(buffer);
- if (count > 0) {
- out.write(buffer, 0, count);
- }
- } while (count >= 0);
- return out.toString("UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(
- "The JVM does not support the compiler's default encoding.", e);
- } catch (IOException e) {
- return null;
- } finally {
- try {
- in.close();
- } catch (IOException ignored) {
- }
- }
- }
-
-}
\ No newline at end of file