BlazeDS Destination destroy()?
-
05-07-2019 - |
質問
BlazeDSの宛先があり、スコープがリクエストに設定されています。要求が完了したときにBlazeDSがdestroy()を呼び出すようにする方法はありますか?リクエストがいつ完了したかを知る別の方法はありますか?
finalize()を使用できることはわかっていますが、ガベージコレクションが発生した場合にのみ呼び出されます。
ありがとう、 マット
解決 2
BlazeDSソースコードを参照した後、カスタムアダプターを使用してこれを実現する方法を見つけました。ここにソースがあります。
package mypackage.adapters;
import java.lang.reflect.Method;
import java.util.Vector;
import flex.messaging.services.remoting.RemotingDestination;
import flex.messaging.services.remoting.adapters.JavaAdapter;
import flex.messaging.util.MethodMatcher;
public class MyAdapter extends JavaAdapter {
protected void saveInstance(Object instance) {
try {
MethodMatcher methodMatcher = ((RemotingDestination)getDestination()).getMethodMatcher();
Method method = methodMatcher.getMethod(instance.getClass(), "destroy", new Vector());
if ( method != null ) {
method.invoke(instance);
}
}
catch ( Exception ex ) {
ex.printStackTrace(System.out);
}
super.saveInstance(instance);
}
}
他のヒント
リクエストハンドラの最後に添付できないのはなぜですか?
所属していません StackOverflow