2

私の GWT アプリは IDEA で書かれています。gwt RPC 呼び出しを行うには、2 つのインターフェイスを作成します。最初の1つ:

RemoteServiceRelativePath("ServerManagement")
public interface ServerManagement extends RemoteService {

String userLogin(String customerId, String login, String password) throws Exception;

ArrayList<PropertyItem> getProperties(String customerId) throws Exception;

void receive(String customerId) throws Exception;

そして2番目の非同期のもの:

public interface ServerManagementAsync {

    void userLogin(String customerId, String login, String password, AsyncCallback<String> asyncCallback);
    void getProperties(String customerId, AsyncCallback<ArrayList<PropertyItem>> asyncCallback);
    void receive(String customerId, AsyncCallback<String> asyncCallback);       
} 

しかし、両方のインターフェイスで、「受信」メソッドの行は赤で線を引き、IDE は次のメッセージを返します。

Methods of asynchronous remote service 'ServerManagementAsync' are not consistent with 'ServerManagement' less... (Ctrl+F1) 
This inspection reports any inconsistency between a methods of synchronous and asynchronous interfaces of remote service

これを修正する方法は?

4

2 に答える 2

2

非同期インターフェイスは次のようにする必要があります。

public interface ServerManagementAsync {

    void userLogin(String customerId, String login, String password, AsyncCallback<String> asyncCallback);
    void getProperties(String customerId, AsyncCallback<ArrayList<PropertyItem>> asyncCallback);
    void receive(String customerId, AsyncCallback<Void> asyncCallback);       
} 

メソッド receive の AsyncCallback <Void> に注意してください。AsyncCallback は、同期インターフェイスのメソッドによって返される Type でパラメーター化する必要があります。

私の悪い英語でごめんなさい。乾杯。

于 2013-05-15T13:24:17.253 に答える
0

上記の回答に同意します。また、IntelliJ IDEA 12 がビルド時にターゲット/生成されたソース フォルダーに非同期インターフェイスを自動生成しようとしたときに、「非同期リモート サービスのメソッドが一貫していません」というまったく同じエラーが表示されたことにも言及したいと思います。これは IDEA のバグだと思います。generated-sources ディレクトリ内の生成された Async インターフェイスに関数を手動で追加すると、エラーが修正され、実際には、Generated-sources フォルダーを削除して再コンパイルしても、将来のコンパイルで IDEA がファイルを正しく生成する原因になりました。

Nikitin の場合、手動でコーディングされた非同期インターフェイスの「receive」メソッドの AsyncCallback パラメータが次のように入力された結果のようです。

AsyncCallback<String>  // does not work - String is not the synchronous method's return type

いつあるべきか

AsyncCallback<Void>   // works, type matches with the synchronous method's return type

受信メソッドの AsyncCallback 型は、ServerManagement.java で定義された同期インターフェイスの受信メソッドの void 戻り型と一致するため、Void である必要があります。

スクリーンショットは次のとおりです。

これらのタイプは一致する必要があります

于 2013-08-10T22:08:14.083 に答える