In this post, we're going to learn, how to create an event gateway in Lucee. Before that, we should know about, what is an Event gateway.
In common, An event gateway is a program, which is continuously monitoring a resource & do necessary actions on certain events. In Lucee, we also have the similar process available. Recent versions of Lucee come up with two built-in event gateways ( Directory watcher & Mail watcher ). But we could create our own event gateways for handling any special scenarios like SASS compilation etc.
Of Course, we should place these files in right location & each file should be in some specific structure. So, i'll mention the right locations, whenever it is needed. Just remember the directory mappings below.
It should be placed in "{{lucee-server}}/context/context/admin/gdriver/demoGateway.cfc".
This is the file, which is responsible for doing the actions whatever we need. This component must contain some public functions inside that.
It should be placed in {{lucee-web}}/lucee/components/lucee/extension/gateway/demoDriver.cfc
.
The driver is used to configure and define your Gateway. Using this, you can define the form fields in the Lucee admin settings page for your gateway. If you need more configurations, you might need to add them as fields array in this driver component. Also it makes sure that your gateway is listed as an available Gateway in the Lucee Admin page.
It should be placed in {{lucee-web}}/lucee/components/lucee/extension/gateway/demoGatewayListener.cfc
.
Listener is component which is used to make the Gateway file as small as we can. If an event occurs for the gateway, it should call a corresponding function from the listener component.
Once all the files are placed in right location, we're all set to create the event gateway instance from Lucee web administrator under menu "Services --> Event Gateway".
While creating the gateway instance from the web administrator, you might need to enter the details that are required for the event gateway as per the fields configuration in driver component.
For more details about creating Event gateways for a specific task, please check one of our blog post about SASS compilation.