
1322
DEVELOPING
COLDFUSION 9 APPLICATIONS
Using External Resources
Las
t
upda
te
d 8/5/2010
GatewayServices class
The Gateway class uses the coldfusion.eventgateway.GatewayServices class to interact with the ColdFusion event
gateway services. This class has the following methods:
CFEvent class
The Gateway class sends and receives CFEvent instances to communicate with the ColdFusion listener CFC or
application. The Gateway notifies ColdFusion of a message by sending a CFEvent instance in a
GatewayServices.addEvent
method. Similarly, the Gateway receives a CFEvent instance when ColdFusion calls the
gateway
outgoingMessage
method.
The CFEvent class extends the java.util.Hashtable class and has the following methods to construct the instance and
set and get its fields. (In CFML, you treat CFEvent instances as structures.)
Signature
Description
GatewayServices
getGatewayServices
Static method that returns the GatewayServices object. Gateway code can call
this method at any time, if necessary.
boolean
addEvent
msg
)
Sends a
CFEvent
instance to ColdFusion for dispatching to a listener CFC. The
event gateway uses this method to send all incoming messages to the
application for processing. Returns False if the event is not added to the queue.
int
getQueueSize
Returns the current size of the ColdFusion event queue. This queue handles all
messages for all gateways.
int
getMaxQueueSize
Returns the maximum size of the ColdFusion event queue, as set in the
ColdFusion Administrator.
Logger
getLogger
Logger
getLogger
logfile)
Returns a ColdFusion Logger object that the event gateway can use to log
information in the eventgateway.log log file (the default) or the specified log file.
The
logfile
attribute must be a filename without a filename extension, such as
mylogifile. ColdFusion places the file in the ColdFusion logs directory and
appends .log to the specified filename.
For information on using the logger object, see “
Logging events and using log
files
” on page
1332.
Methods
Description
CFEvent
gatewayID)
CFEvent constructor. The
gatewayID
parameter must be the value that is passed
in the gateway constructor or set using the Gateway
setGatewayID
method.
void
setGatewayType
type)
String
getGatewayType
Identifies the type of event gateway, such as SMS. For the sake of consistency,
use this name in the Type Name field when you add an event gateway type on
the Gateway Types page in the ColdFusion Administrator.
void
setData
data)
Map
getData
The event data; includes the message being passed to or from ColdFusion. The
content of the field depends on the event gateway type. The Map keys must be
strings.
Because ColdFusion is not case sensitive, it converts the Map passed in the
setData
method to a case-insensitive Map. As a result, do not create entries in
the data with names that differ only in case.
void
setOriginatorID
id)
String
getOriginatorID
Identifies the originator of an incoming message or the destination of an
outgoing message. The value depends on the protocol or event gateway type.
void
setCFCPath
path)
String
getCFCPath
An absolute path to the application listener CFC that processes the event. By
default, ColdFusion uses the first path configured for the event gateway
instance on the Event Gateways page in the ColdFusion Administrator.