Blazeds 목적지 파괴 ()?
-
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