BlazeDS Destination destroy ()?
-
05-07-2019 - |
Domanda
Ho una destinazione BlazeDS e l'ambito è impostato su richiesta. C'è un modo per convincere BlazeDS a chiamare destro () al termine della richiesta? C'è un altro modo per sapere quando la richiesta è completa?
So di poter usare finalize (), ma viene chiamato solo quando si verifica la garbage collection.
Grazie, Matt
Soluzione 2
Dopo aver sfogliato il codice sorgente di BlazeDS ho capito come farlo usando un adattatore personalizzato. Ecco la fonte.
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);
}
}
Altri suggerimenti
Perché non puoi collegarlo alla fine del gestore delle richieste?
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow