|
ColdBox Platform Version 3.7.0 | ||||
FRAMES |
WEB-INF.cftags.componentcoldbox.system.orm.hibernate.WBEventHandler
public class 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 | |
---|---|
private any |
announceInterception(string state, [any data='[runtime expression]'])
Process a wirebox event |
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 |
---|
|
Method Detail |
---|
private any announceInterception(string state, [any data='[runtime expression]'])
state
data
private any getORMUtil()
private any getWireBox()
public void postDelete([any entity])
postDelete
in interface
CFIDE.orm.IEventHandler
entity
public void postInsert([any entity])
postInsert
in interface
CFIDE.orm.IEventHandler
entity
public void postLoad([any entity])
postLoad
in interface
CFIDE.orm.IEventHandler
entity
public void postNew([any entity], [any entityName])
entity
entityName
public void postSave([any entity])
entity
public void postUpdate([any entity])
postUpdate
in interface
CFIDE.orm.IEventHandler
entity
public void preDelete([any entity])
preDelete
in interface
CFIDE.orm.IEventHandler
entity
public void preInsert([any entity])
preInsert
in interface
CFIDE.orm.IEventHandler
entity
public void preLoad([any entity])
preLoad
in interface
CFIDE.orm.IEventHandler
entity
public void preSave([any entity])
entity
public void preUpdate([any entity], [struct oldData='[runtime expression]'])
preUpdate
in interface
CFIDE.orm.IEventHandler
entity
oldData
private any processEntityInjection(any entityName, any entity)
entityName
entity
|
ColdBox Platform Version 3.7.0 | ||||
FRAMES |