Question

I have a BlazeDS destination and the scope is set to request. Is there a way to get BlazeDS to call destroy() when the request is complete? Is there another way to know when the request is complete?

I know I can use finalize(), but that is only called when garbage collection occurs.

Thanks, Matt

Was it helpful?

Solution 2

After browsing through the BlazeDS source code I figured out how to accomplish this by using a custom adapter. Here is the source.

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);
    }
}

OTHER TIPS

Why can't you attach it to the end of your request handler?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top