我有一个BlazeDS目的地,作用域设置为request。有没有办法让BlazeDS在请求完成时调用destroy()?有没有其他方法可以知道请求何时完成?
我知道我可以使用finalize(),但它只在垃圾收集发生时调用。
谢谢,马特
发布于 2009-10-23 03:05:45
在浏览了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);
}
}发布于 2009-10-23 02:39:15
为什么不能将其附加到请求处理程序的末尾?
https://stackoverflow.com/questions/1609041
复制相似问题