繁体   English   中英

BlazeDS Destination destroy()?

[英]BlazeDS Destination destroy()?

我有一个BlazeDS目标,并且范围设置为request。 请求完成后,是否有办法让BlazeDS调用destroy()? 还有另一种方法可以知道请求何时完成?

我知道我可以使用finalize(),但这仅在发生垃圾回收时才调用。

谢谢,马特

为什么不能将其附加到请求处理程序的末尾?

浏览完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);
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM