Skip to content
This repository
Browse code

Adds support for manually kicking off an instance's destruction with …

…Injector#destroyInstance
  • Loading branch information...
commit e31fa2b588f62f34fb28b4f3f914d0c2d9aa6a02 1 parent 8191b1a
Till Schneidereit authored June 02, 2012
66  src/org/swiftsuspenders/injection/Injector.as
@@ -255,28 +255,6 @@ package org.swiftsuspenders.injection
255 255
 		}
256 256
 
257 257
 		/**
258  
-		 * Uses the <code>TypeDescription</code> the injector associates with the given instance's
259  
-		 * type to iterate over all <code>[PreDestroy]</code> methods in the instance, supporting
260  
-		 * automated destruction.
261  
-		 *
262  
-		 * @param instance The instance to destroy
263  
-		 */
264  
-		public function destroyInstance(instance : Object) : void
265  
-		{
266  
-			if (!instance)
267  
-			{
268  
-				return;
269  
-			}
270  
-			const type : Class = _reflector.getClass(instance);
271  
-			const typeDescription : TypeDescription = getTypeDescription(type);
272  
-			for (var preDestroyHook : PreDestroyInjectionPoint = typeDescription.preDestroyMethods;
273  
-			     preDestroyHook; preDestroyHook = PreDestroyInjectionPoint(preDestroyHook.next))
274  
-			{
275  
-				preDestroyHook.applyInjection(instance, type, this);
276  
-			}
277  
-		}
278  
-
279  
-		/**
280 258
 		 * Indicates whether the injector can supply a response for the specified dependency either
281 259
 		 * by using a mapping of its own or by querying one of its ancestor injectors.
282 260
 		 *
@@ -385,15 +363,25 @@ package org.swiftsuspenders.injection
385 363
 		}
386 364
 
387 365
 		/**
388  
-		 * Returns a description of the given type containing its constructor, injection points
389  
-		 * and post construct and pre destroy hooks
  366
+		 * Uses the <code>TypeDescription</code> the injector associates with the given instance's
  367
+		 * type to iterate over all <code>[PreDestroy]</code> methods in the instance, supporting
  368
+		 * automated destruction.
390 369
 		 *
391  
-		 * @param type The type to describe
392  
-		 * @return The TypeDescription containing all information the injector has about the type
  370
+		 * @param instance The instance to destroy
393 371
 		 */
394  
-		public function getTypeDescription(type : Class) : TypeDescription
  372
+		public function destroyInstance(instance : Object) : void
395 373
 		{
396  
-			return _reflector.describeInjections(type);
  374
+			if (!instance)
  375
+			{
  376
+				return;
  377
+			}
  378
+			const type : Class = _reflector.getClass(instance);
  379
+			const typeDescription : TypeDescription = getTypeDescription(type);
  380
+			for (var preDestroyHook : PreDestroyInjectionPoint = typeDescription.preDestroyMethods;
  381
+			     preDestroyHook; preDestroyHook = PreDestroyInjectionPoint(preDestroyHook.next))
  382
+			{
  383
+				preDestroyHook.applyInjection(instance, type, this);
  384
+			}
397 385
 		}
398 386
 
399 387
 		/**
@@ -447,11 +435,33 @@ package org.swiftsuspenders.injection
447 435
 			return _applicationDomain;
448 436
 		}
449 437
 
  438
+		/**
  439
+		 * Instructs the injector to use the description for the given type when constructing or
  440
+		 * destroying instances.
  441
+		 *
  442
+		 * The description consists details for the constructor, all properties and methods to
  443
+		 * inject into during construction and all methods to invoke during destruction.
  444
+		 *
  445
+		 * @param type
  446
+		 * @param description
  447
+		 */
450 448
 		public function addTypeDescription(type : Class, description : TypeDescription) : void
451 449
 		{
452 450
 			_classDescriptor.addDescription(type, description);
453 451
 		}
454 452
 
  453
+		/**
  454
+		 * Returns a description of the given type containing its constructor, injection points
  455
+		 * and post construct and pre destroy hooks
  456
+		 *
  457
+		 * @param type The type to describe
  458
+		 * @return The TypeDescription containing all information the injector has about the type
  459
+		 */
  460
+		public function getTypeDescription(type : Class) : TypeDescription
  461
+		{
  462
+			return _reflector.describeInjections(type);
  463
+		}
  464
+
455 465
 
456 466
 		//----------------------             Internal Methods               ----------------------//
457 467
 		SsInternal static function purgeInjectionPointsCache() : void

0 notes on commit e31fa2b

Please sign in to comment.
Something went wrong with that request. Please try again.