2012-06-22 4 views
0

저는 AppEngine에서 호스팅되는 프로젝트에서 일하고 있습니다. 브라우저 클라이언트의 경우 클라이언트의 GIN과 GUICE를 사용하는 GWTP 플랫폼을 사용하고 있습니다. 또한 모델, 발표자, 작업 및 이벤트를 사용합니다.android에서 파견 작업을 사용하는 방법

나는 서비스에 대한 안드로이드 클라이언트를 작성하려고 생각하고 있지만 웹 서비스와 데이터를 연결하고 교환하는 방법을 모르므로 시작하는 방법을 알지 못합니다. 브라우저 클라이언트에 사용하는 액션 및 액션 핸들러 (http://code.google.com/p/gwt-platform/wiki/GettingStartedDispatch)를 사용해야합니다. 안드로이드에서 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"); 

    } 

}; 

가 어떻게 안드로이드에서이를 구현 할 수 있습니까? 누군가가 내게 모범을 보이거나이 문제가 생길 수 있습니까?

저는 AppEngine SDK 1.6.4, GWT SDK 2.4.0, Eclipse 용 GWTP 플러그인 및 Eclipse 용 GPE 플러그인을 사용하고 있습니다.

답변

1

ADT 용 GAE 플러그인에서 영감을 얻기 위해 'App Engine Connected Android apps'에 대한 소스를 볼 수 있습니다. 그들은 안드로이드의 HttpClient를 사용하여 GWT 엔드 포인트를 호출함으로써 비슷한 것을하고있다.

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

+0

안녕하세요. 고마워, 난 그 프로젝트를 보았지만 잘 일식에 대한 GWTP 플러그인과 통합 할 때 작동하지 않습니다. appwine과 Android 클라이언트로 gwt-platform 플러그인을 병합하는 방법에 대한 간단한 샘플 만 있으면됩니다. 그걸 도와 주실 수 있나요, 아니면 적어도 모든 일의 흐름에 대한 힌트를 주시겠습니까? – Berry

+0

마법사를 사용하여 작은 테스트 프로젝트를 만들고 소스 코드를 체크 아웃하십시오. 그것은 당신의 프로젝트를 위해 작동하지 않을 수도 있지만, 당신은 안드로이드 측면을 구현하는 방법에 대한 아이디어를 얻을 것이다. –

+0

@ NikolayElenkov 당신은 클라이언트를위한 안드로이드 애플 리케이션을 만들고 싶니? 또는 동일한 앱을 사용하지만 Android 관련 웹보기 기능을 사용하여 모바일 호환이 가능합니까? – iMBMT