1 8 9 15 package jfun.yan.lifecycle; 16 17 import jfun.yan.Component; 18 19 29 public class DefaultLifecycleManager extends LifecycleManager { 30 private final DefaultLifecycleDescriptor desc; 31 32 36 public DefaultLifecycleManager(DefaultLifecycleDescriptor desc) { 37 this.desc = desc; 38 } 39 43 public DefaultLifecycleManager(){ 44 this(new DefaultLifecycleDescriptor()); 45 } 46 50 public void close() 51 throws Throwable { 52 desc.close(this); 53 } 54 58 public void dispose() 59 throws Throwable { 60 desc.dispose(this); 61 } 62 66 public void init() 67 throws Throwable { 68 desc.init(this); 69 } 70 74 public void verify() 75 throws Throwable { 76 desc.verify(this); 77 } 78 82 public void open() 83 throws Throwable { 84 desc.open(this); 85 } 86 90 public void start() 91 throws Throwable { 92 desc.start(this); 93 } 94 98 public void stop() 99 throws Throwable { 100 desc.stop(this); 101 } 102 105 public DefaultLifecycle newLifecycle(){ 106 return new DefaultLifecycle(); 107 } 108 112 public class DefaultLifecycle extends Lifecycle{ 113 119 public DefaultLifecycle opener(Procedure proc, boolean reentrant){ 120 desc.opener(this, proc, reentrant); 121 return this; 122 } 123 129 public DefaultLifecycle closer(Procedure proc, boolean reentrant){ 130 desc.closer(this, proc, reentrant); 131 return this; 132 } 133 139 public DefaultLifecycle initializer(Procedure proc, boolean reentrant){ 140 desc.initializer(this, proc, reentrant); 141 return this; 142 } 143 149 public DefaultLifecycle disposer(Procedure proc, boolean reentrant){ 150 desc.disposer(this, proc, reentrant); 151 return this; 152 } 153 159 public DefaultLifecycle verifier(Procedure proc, boolean reentrant){ 160 desc.verifier(this, proc, reentrant); 161 return this; 162 } 163 169 public DefaultLifecycle starter(Procedure proc, boolean reentrant){ 170 desc.starter(this, proc, reentrant); 171 return this; 172 } 173 179 public DefaultLifecycle stopper(Procedure proc, boolean reentrant){ 180 desc.stopper(this, proc, reentrant); 181 return this; 182 } 183 188 public DefaultLifecycle opener(Procedure proc){ 189 desc.opener(this, proc); 190 return this; 191 } 192 197 public DefaultLifecycle closer(Procedure proc){ 198 desc.closer(this, proc); 199 return this; 200 } 201 206 public DefaultLifecycle initializer(Procedure proc){ 207 desc.initializer(this, proc); 208 return this; 209 } 210 215 public DefaultLifecycle disposer(Procedure proc){ 216 desc.disposer(this, proc); 217 return this; 218 } 219 224 public DefaultLifecycle verifier(Procedure proc){ 225 desc.verifier(this, proc); 226 return this; 227 } 228 233 public DefaultLifecycle starter(Procedure proc){ 234 desc.starter(this, proc); 235 return this; 236 } 237 242 public DefaultLifecycle stopper(Procedure proc){ 243 desc.stopper(this, proc); 244 return this; 245 } 246 251 public DefaultLifecycle opener(String method_name){ 252 opener(Procedures.method(method_name)); 253 return this; 254 } 255 260 public DefaultLifecycle closer(String method_name){ 261 closer(Procedures.method(method_name)); 262 return this; 263 } 264 269 public DefaultLifecycle initializer(String method_name){ 270 initializer(Procedures.method(method_name)); 271 return this; 272 } 273 278 public DefaultLifecycle disposer(String method_name){ 279 disposer(Procedures.method(method_name)); 280 return this; 281 } 282 287 public DefaultLifecycle verifier(String method_name){ 288 verifier(Procedures.method(method_name)); 289 return this; 290 } 291 296 public DefaultLifecycle starter(String method_name){ 297 starter(Procedures.method(method_name)); 298 return this; 299 } 300 305 public DefaultLifecycle stopper(String method_name){ 306 stopper(Procedures.method(method_name)); 307 return this; 308 } 309 314 public Component manage(Component c){ 315 if(this.isEmpty()) return c; 316 return withLifecycle(c, this); 317 } 318 319 323 public void manageInstance(Object obj){ 324 if(this.isEmpty()) return; 325 addLiveObject(bear(obj)); 326 } 327 } 328 } 329 | Popular Tags |