0

私は AppEngine でホストされているプロジェクトに取り組んでおり、ブラウザー クライアントの場合、GIN (クライアント上) とサーバー上で GUICE を使用することを意味する GWTP プラットフォームを使用しています。また、モデル、プレゼンター、アクション、およびイベントを使用します。

サービス用のAndroidクライアントも作成することを考えていますが、Webサービスに接続してデータを交換する方法がわからないため、開始方法がわかりません。ブラウザー クライアントに使用するアクションとアクション ハンドラー ( http://code.google.com/p/gwt-platform/wiki/GettingStartedDispatch ) を使用する必要があります。Android からは、RPC を使用する方法しか知りません。接続を確立できません。デバイスからサーバーにクラスをマップする方法がわかりません。

たとえば、GWTP を使用して、ブラウザー クライアントでサーバー上で何かを実行したい場合、Action クラス、ActionResult クラス (両方ともクライアント上)、および ActionHandler クラス (サーバー上) を実装します。アクションをディスパッチするには DispatchAsync インターフェイスを使用し、結果を取得するには AsyncCallback を使用します。

アクション (クライアント上) - SendRoadNotification.java :

public class SendRoadNotification extends
    ActionImpl<SendRoadNotificationResult> {

private RoadNotification roadNot;



@SuppressWarnings("unused")
private SendRoadNotification() {
    // For serialization only
    }

public SendRoadNotification(RoadNotification roadNot) {
    this.roadNot = roadNot;
    }

public RoadNotification getRoadNot() {
    return roadNot;
    }
}

ActionResult (クライアント上) -- SendRoadNotfifcationResult.java :

public class SendRoadNotificationResult implements Result {

private RoadNotification roadNot;

@SuppressWarnings("unused")
private SendRoadNotificationResult() {
    // For serialization only
    }

public SendRoadNotificationResult(RoadNotification roadNot) {
    this.roadNot = roadNot;
    }

public RoadNotification getRoadNot() {
    return roadNot;
    }
}

ActionHandler (サーバー上) -- SendRoadNotificationActionHandler.java:

public class SendRoadNotificationActionHandler implements
    ActionHandler<SendRoadNotification, SendRoadNotificationResult> {

static DataStore ds = DataStore.getDatastoreService();

@Inject
public SendRoadNotificationActionHandler() {
    }

@Override
public SendRoadNotificationResult execute(SendRoadNotification action,
        ExecutionContext context) throws ActionException {

                        //Here I am doing something with that action
    }

@Override
public void undo(SendRoadNotification action,
        SendRoadNotificationResult result, ExecutionContext context)
        throws ActionException {
    }

@Override
public Class<SendRoadNotification> getActionType() {
    return SendRoadNotification.class;
        }
}

私がそれらを使用する方法は次のとおりです。

    SendRoadNotification action = new SendRoadNotification(rn);
            dispatchAsync.execute(action, sendRoadNotifCallback);

そしてコールバック:

AsyncCallback<SendRoadNotificationResult> sendRoadNotifCallback = new AsyncCallback<SendRoadNotificationResult>() {

    @Override
    public void onSuccess(SendRoadNotificationResult result) {


    }

    @Override
    public void onFailure(Throwable caught) {
        Window.alert("Something went wrong");

    }

};

これを Android に実装するにはどうすればよいですか? 誰かが私に例を教えてくれますか、または以前にこの問題を抱えていましたか?

AppEngine sdk 1.6.4、GWT sdk 2.4.0、Eclipse 用の GWTP プラグイン、および Eclipse 用の GPE プラグインを使用しています。

4

1 に答える 1

1

インスピレーションを得るために、ADT用のGAEプラグインが「AppEngineConnectedAndroidアプリ」用に生成するソースを確認することをお勧めします。彼らは、AndroidのHttpClientを使用してGWTエンドポイントを呼び出すことで同様のことを行っています。

https://developers.google.com/eclipse/docs/appengine_connected_android

于 2012-06-22T07:39:06.547 に答える