1

Lotus Notes Java ライブラリは 32​​ ビット JVM でのみ実行され、64 ビット JVM アプリから呼び出す必要があるため、RMI ブリッジを作成しました。64 ビット アプリは 32​​ ビット RMI サーバーを実行し、 Lotus Notes 呼び出しを行うための 32 ビット サーバー。

Lotus Notes では、(Lotus Notes 関数を呼び出す) 各スレッドが lotus.domino.NotesThread.sinitThread(); を呼び出す必要があります。他の Lotus Notes 関数を呼び出す前に実行し、最後に un-init 関数を呼び出してクリーンアップします。これらの呼び出しはコストがかかる可能性があります。

RMI はシングルスレッドの実行を保証しないため、Lotus Notes 用に初期化された単一のスレッドにすべての要求をパイプするにはどうすればよいですか? 私は他の RPC/「ブリッジ」メソッドにもオープンです (Java の使用を好みます)。現在、定義したすべての RMI 関数呼び出しで、そのスレッドが初期化されていることを確認する必要があります。

4

2 に答える 2

1

シングル スレッド エグゼキュータ サービスを使用し、ロータス ノーツ メソッドを呼び出すたびに、タスクをエグゼキュータに送信し、返された Future を取得し、Future からメソッド呼び出しの結果を取得します。

たとえば、メソッドを呼び出すにはBar getFoo()、次のコードを使用します。

Callable<Bar> getFoo = new Callable<Bar>() {
    @Override
    public Bar call() {
        return lotuNotes.getFoo();
    }
};
Future<Bar> future = executor.submit(getFoo);
return future.get();
于 2012-12-18T19:46:34.080 に答える
0

getName() は単純な例であるため、各コードはこの種の処理を取得します (これによりコードが非常に肥大化しますが、機能します!)

    @Override
    public String getName() throws RemoteException, NotesException {
        java.util.concurrent.Callable<String> callableRoutine =
                new java.util.concurrent.Callable<String>() {

                    @Override
                    public String call() throws java.rmi.RemoteException, NotesException {
                        return lnView.getName();
                    }
                };
        try {
            return executor.submit(callableRoutine).get();
        } catch (Exception ex) {
            handleExceptions(ex);
            return null; // not used
        }
    }


/**
 * Handle exceptions from serializing to a thread.
 *
 * This routine always throws an exception, does not return normally.
 *
 * @param ex
 * @throws java.rmi.RemoteException
 * @throws NotesException
 */
private void handleExceptions(Throwable ex) throws java.rmi.RemoteException, NotesException {
    if (ex instanceof ExecutionException) {
        Throwable t = ex.getCause();
        if (t instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException) ex.getCause();
        } else if (t instanceof NotesException) {
            throw (NotesException) ex.getCause();
        } else {
            throw new NotesException(LnRemote.lnErrorRmi, utMisc.getExceptionMessageClean(t), t);
        }
    } else {
        throw new NotesException(LnRemote.lnErrorRmi, utMisc.getExceptionMessageClean(ex), ex);
    }
}
于 2012-12-18T23:10:17.627 に答える