1 28 29 package com.caucho.util; 30 31 import java.lang.ref.WeakReference ; 32 33 42 public class WeakAlarm extends Alarm { 43 private WeakReference <AlarmListener> _listenerRef; 44 private WeakReference <ClassLoader > _loaderRef; 45 46 47 51 public WeakAlarm(AlarmListener listener) 52 { 53 super(listener); 54 } 55 56 60 public WeakAlarm(String name, AlarmListener listener) 61 { 62 super(name, listener); 63 } 64 65 72 public WeakAlarm(String name, AlarmListener listener, long delta) 73 { 74 super(name, listener, delta); 75 } 76 82 public WeakAlarm(AlarmListener listener, long delta) 83 { 84 this(listener); 85 86 queue(delta); 87 } 88 89 92 public AlarmListener getListener() 93 { 94 return _listenerRef.get(); 95 } 96 97 100 public void setListener(AlarmListener listener) 101 { 102 _listenerRef = new WeakReference <AlarmListener>(listener); 103 } 104 105 108 public void setContextLoader(ClassLoader loader) 109 { 110 if (loader != null) 111 _loaderRef = new WeakReference <ClassLoader >(loader); 112 else 113 _loaderRef = null; 114 } 115 } 116 | Popular Tags |