1 28 29 package com.caucho.loader; 30 31 import com.caucho.log.Log; 32 import com.caucho.util.L10N; 33 34 import java.lang.ref.WeakReference ; 35 import java.lang.reflect.Method ; 36 import java.util.logging.Level ; 37 import java.util.logging.Logger ; 38 39 42 public class WeakDestroyListener implements EnvironmentListener { 43 private static final L10N L = new L10N(WeakDestroyListener.class); 44 private static final Logger log = Log.open(WeakDestroyListener.class); 45 46 private Method _preDestroy; 47 private WeakReference <Object > _objRef; 48 49 54 public WeakDestroyListener(Method preDestroy, Object obj) 55 { 56 _preDestroy = preDestroy; 57 58 _objRef = new WeakReference <Object >(obj); 59 } 60 61 64 public void environmentStart(EnvironmentClassLoader loader) 65 { 66 } 67 68 71 public void environmentStop(EnvironmentClassLoader loader) 72 { 73 Object obj = _objRef.get(); 74 if (obj == null) 75 return; 76 77 try { 78 _preDestroy.invoke(obj, (Object []) null); 79 } catch (Throwable e) { 80 log.log(Level.WARNING, e.toString(), e); 81 } 82 } 83 } 84 85 | Popular Tags |