tracker issue : CF-3042139

select a category, or use search below
(searches all categories and all time range)
Title:

Bug 84112:(Watson Migration Closure)Provide some sort of hook or event handler that can be notified when a new CFC instance is created with new or CreateObject

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/

Reporter/Name(from Bugbase): Brian Kotek / Brian Kotek (brian428)

Created: 09/09/2010

Components: CFComponent, Components

Versions: 9.0.1

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 /

Priority/Frequency: Normal / Most users will encounter

Locale/System: English / Platforms All

Vote Count: 1

Duplicate ID:	CF-3687747

Problem:

Provide some sort of hook or event handler that can be notified when a new CFC instance is created with new or CreateObject. One option might be a new annotation option on the cfcomponent tag such as eventHandler='com.foo.MyEventHandlerCFC'. I think it really only needs to implement an onInstantiate( any newCFC ) method. By making it an annotation, the overhead of notifying the event handler would only happen for CFCs where it is desired. Or, if a global handler is desired, you could also support adding this as a config option in Application.cfc. onInstantiate() (or whatever it is called) would pass the new CFC as an argument, and return a CFC. The CFC that is returned would actually be the instance that is provided to the caller (i.e. whatever is calling new or CreateObject).The benefit of doing this would be to allow other code to run in response to the object being created, such as having ColdSpring wire it. In most cases the CFC passed in would be the one that onInstantiate returns, but allowing what is returned to be modified would open many interesting possibilities, such as automatically creating a proxy for the original object, etc. Since we don't have the ability to do bytecode manipulation (i.e. ASM) or built-in AOP (i.e. AspectJ), something like this would seem to offer a great deal of flexibility.
Method:


Result:

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3042139

External Customer Info:
External Company:  
External Customer Name: Brian Kotek
External Customer Email: 27EF5CB74460F39E99201549
External Test Config: 09/09/2010

Attachments:

Comments: