2009-10-22 3 views
0

BlazeDS 대상이 있고 범위가 요청하도록 설정되어 있습니다. 요청이 완료되면 BlazeDS가 destroy()를 호출 할 수있는 방법이 있습니까? 요청이 완료된 때를 알 수있는 또 다른 방법이 있습니까?BlazeDS 대상 destroy()?

finalize()를 사용할 수 있지만 가비지 수집이 발생할 때만 호출된다는 것을 알고 있습니다.

덕분에, 매트

답변

0

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

2 일 동안 답변으로 표시 할 수 없음 :( –

0

왜 당신은 당신의 요청 처리기의 말미에 첨부 할 수 없습니다?

+0

서비스에 많은 핸들러가 있지만 항상 destroy()를 호출해야합니다. –