Skip to content
Andrea Campolonghi edited this page Aug 17, 2010 · 9 revisions

Requirments

  • CF9 +
  • Railo 3.2.018 +

Installation

  • Copy the package “com” into your webroot. If deployed in another location a mapping to the /com
    location is required.
  • CFEM uses logobx as default logger. You will need to copy the logbox folder into your webroot or providing a mapping to it. More on logging in the custom configurations section.
  • “ColdSpring” is required is you plan to use the autowiring utility that CFEM provide for events and listeners. You can grab a coldspring copy here : http://www.coldspringframework.org/

Create a CFEM instance

Creating an instance of the EventManager is very easy:

import "com.andreacfm.cfem.*";
application.em = new EventManager();

At this point we have a CFEM instance that is missing on any event or listener configuration.

var listener = new myListener();
    application.em.addEvent(name= "onMyFirstEvent");
    application.em.addEventListener(event = "onMyFirstEvent",listener = listener, method = "mymethod");

We have now provided the minimal configuration to make CFEM usefull. We registered an event and we subscribed a listener to be invoked when that event is fired.

var data = {name = 'andrea'};
var event = application.em.createEvent(name = "onMyEvent",data = data, mode = "asynch");
application.em.dispatchEvent(event);

An event is created and dispatched. Note that the event will carry some data with him and that will be fired inside of an asyncronous thread.
CFEM will now invoke for you the method “myMethod” on the listener object passing the event object as only arguments.

Simply like this. Just a matter of events, listeners, decoupling things and keep your applications extensible.