WEB-INF.cftags.component coldbox.system.orm.hibernate.WBEventHandler
******************************************************************************* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.coldbox.org | www.luismajano.com | www.ortussolutions.com ******************************************************************************* Description : This class can be used directly or inherited from for more granular control of ORM injections. This bridges Hibernate to WireBox so you can wire up ORM entities in your application. Please also note that there is no way to intercept new() or entityNew() or createObject() calls done via ColdFusion and there is no preNew interception point exposed by ColdFusion. So if you want ORM entity injection enabled for new entities, you will have to send them manually into wirebox for wiring like so: wirebox.autowire( entity ); All loaded entities will be wired for you during the postLoad() ORM event handler. This event handler will also announce WireBox events according to hibernate events, so you can create WireBox listeners and perform certain actions on entities. The announced events are: - ORMPreLoad - ORMPostLoad - ORMPreDelete - ORMPostDelete - ORMPreUpdate - ORMPostUpdate - ORMPreInsert - ORMPostInsert - ORMPreSave - ORMPostSave This class requires that WireBox be in application scope in a key called 'wirebox'. You can override this key by using a private variable in your own implementation. To use: 1) In your Application.cfc orm settings point it directly to this file this.ormsettings.eventHandling = true; this.ormsettings.eventHandler = "wirebox.system.orm.hibernate.WBEventHandler"; 2) Create a CFC that inherits from "wirebox.system.orm.hibernate.WBEventHandler" and place it somewhere in your app. Add the orm settings in your Application.cfc this.ormsettings.eventHandling = true; this.ormsettings.eventHandler = "model.EventHandler"; If you do the latter, you can use some extra functionality by using the following private variables. // The scope key wirebox is located in application scope scopeKey = "wirebox"; // Include list of ORM entities to include in the injection, if blank it includes all, which is the default injectorInclude = ""; // Exclude list of ORM entities to exclude in the injection, if blank it includes none, which is the default injectorExclude = "";
Method Summary | |
---|---|
any
|
announceInterception(string state, [any data='[runtime expression]'])
Process a wirebox event. |
any
|
getEventManager()
Get the system Event Manager. |
private any
|
getORMUtil()
Get ORM Util. |
private any
|
getWireBox()
Get a reference to WireBox. |
void
|
postDelete([any entity])
postDelete called by hibernate which in turn announces a WireBox interception: ORMPostDelete. |
void
|
postInsert([any entity])
postInsert called by hibernate which in turn announces a WireBox interception: ORMPostInsert. |
void
|
postLoad([any entity])
postLoad called by hibernate which in turn announces a WireBox interception: ORMPostLoad. |
void
|
postNew([any entity], [any entityName])
postNew called by ColdBox which in turn announces a coldbox interception: ORMPostNew. |
void
|
postSave([any entity])
postSave called by WireBox Base service after transaction commit or rollback via the save() method. |
void
|
postUpdate([any entity])
postUpdate called by hibernate which in turn announces a WireBox interception: ORMPostUpdate. |
void
|
preDelete([any entity])
preDelete called by hibernate which in turn announces a WireBox interception: ORMPreDelete. |
void
|
preInsert([any entity])
preInsert called by hibernate which in turn announces a WireBox interception: ORMPreInsert. |
void
|
preLoad([any entity])
preLoad called by hibernate which in turn announces a WireBox interception: ORMPreLoad. |
void
|
preSave([any entity])
preSave called by WireBox Base service before save() calls. |
void
|
preUpdate([any entity], [struct oldData='[runtime expression]'])
preUpdate called by hibernate which in turn announces a WireBox interception: ORMPreUpdate. |
private any
|
processEntityInjection(any entityName, any entity)
Process entity injection. |
Methods inherited from class WEB-INF.cftags.component |
---|
None |
Method Detail |
---|
Process a wirebox event
state
data
Get the system Event Manager
Get ORM Util
Get a reference to WireBox
postDelete called by hibernate which in turn announces a WireBox interception: ORMPostDelete
postDelete
in interface
CFIDE.orm.IEventHandler
entity
postInsert called by hibernate which in turn announces a WireBox interception: ORMPostInsert
postInsert
in interface
CFIDE.orm.IEventHandler
entity
postLoad called by hibernate which in turn announces a WireBox interception: ORMPostLoad
postLoad
in interface
CFIDE.orm.IEventHandler
entity
postNew called by ColdBox which in turn announces a coldbox interception: ORMPostNew
entity
entityName
postSave called by WireBox Base service after transaction commit or rollback via the save() method
entity
postUpdate called by hibernate which in turn announces a WireBox interception: ORMPostUpdate
postUpdate
in interface
CFIDE.orm.IEventHandler
entity
preDelete called by hibernate which in turn announces a WireBox interception: ORMPreDelete
preDelete
in interface
CFIDE.orm.IEventHandler
entity
preInsert called by hibernate which in turn announces a WireBox interception: ORMPreInsert
preInsert
in interface
CFIDE.orm.IEventHandler
entity
preLoad called by hibernate which in turn announces a WireBox interception: ORMPreLoad
preLoad
in interface
CFIDE.orm.IEventHandler
entity
preSave called by WireBox Base service before save() calls
entity
preUpdate called by hibernate which in turn announces a WireBox interception: ORMPreUpdate
preUpdate
in interface
CFIDE.orm.IEventHandler
entity
oldData
Process entity injection
entityName
entity