ColdBox Platform Version 3.7.0

coldbox.system.orm.hibernate
Class WBEventHandler

WEB-INF.cftags.component
        extended by coldbox.system.orm.hibernate.WBEventHandler
All Implemented Interfaces:
CFIDE.orm.IEventHandler

public class WBEventHandler
extends WEB-INF.cftags.component

******************************************************************************* 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

announceInterception

private any announceInterception(string state, [any data='[runtime expression]'])
Process a wirebox event

Parameters:
state
data

getORMUtil

private any getORMUtil()
Get ORM Util


getWireBox

private any getWireBox()
Get a reference to WireBox


postDelete

public void postDelete([any entity])
postDelete called by hibernate which in turn announces a WireBox interception: ORMPostDelete

Specified by:
postDelete in interface CFIDE.orm.IEventHandler
Parameters:
entity

postInsert

public void postInsert([any entity])
postInsert called by hibernate which in turn announces a WireBox interception: ORMPostInsert

Specified by:
postInsert in interface CFIDE.orm.IEventHandler
Parameters:
entity

postLoad

public void postLoad([any entity])
postLoad called by hibernate which in turn announces a WireBox interception: ORMPostLoad

Specified by:
postLoad in interface CFIDE.orm.IEventHandler
Parameters:
entity

postNew

public void postNew([any entity], [any entityName])
postNew called by ColdBox which in turn announces a coldbox interception: ORMPostNew

Parameters:
entity
entityName

postSave

public void postSave([any entity])
postSave called by WireBox Base service after transaction commit or rollback via the save() method

Parameters:
entity

postUpdate

public void postUpdate([any entity])
postUpdate called by hibernate which in turn announces a WireBox interception: ORMPostUpdate

Specified by:
postUpdate in interface CFIDE.orm.IEventHandler
Parameters:
entity

preDelete

public void preDelete([any entity])
preDelete called by hibernate which in turn announces a WireBox interception: ORMPreDelete

Specified by:
preDelete in interface CFIDE.orm.IEventHandler
Parameters:
entity

preInsert

public void preInsert([any entity])
preInsert called by hibernate which in turn announces a WireBox interception: ORMPreInsert

Specified by:
preInsert in interface CFIDE.orm.IEventHandler
Parameters:
entity

preLoad

public void preLoad([any entity])
preLoad called by hibernate which in turn announces a WireBox interception: ORMPreLoad

Specified by:
preLoad in interface CFIDE.orm.IEventHandler
Parameters:
entity

preSave

public void preSave([any entity])
preSave called by WireBox Base service before save() calls

Parameters:
entity

preUpdate

public void preUpdate([any entity], [struct oldData='[runtime expression]'])
preUpdate called by hibernate which in turn announces a WireBox interception: ORMPreUpdate

Specified by:
preUpdate in interface CFIDE.orm.IEventHandler
Parameters:
entity
oldData

processEntityInjection

private any processEntityInjection(any entityName, any entity)
Process entity injection

Parameters:
entityName
entity

ColdBox Platform Version 3.7.0