User Guide

Table Of Contents
Building an event gateway 1093
The sample Socket event gateway has a single constructor that takes two parameters. It tries to
load a configuration file. If you specify a configuration file in the ColdFusion MX Administrator,
or the file path is invalid, it gets an IO exception. It then uses the default port and logs a message
indicating what it did. The following example shows the Gateway constructor code and the
loadProperties method it uses:
public SocketGateway(String id, String configpath)
{
gatewayID = id;
gatewayService = GatewayServices.getGatewayServices();
// log things to socket-gateway.log in the CF log directory
log = gatewayService.getLogger("socket-gateway");
propsFilePath=configpath;
try
{
FileInputStream propsFile = new FileInputStream(propsFilePath);
properties.load(propsFile);
propsFile.close();
this.loadProperties();
}
catch (IOException e)
{
// Use default value for port and log the status.
log.warn("SocketGateway(" + gatewayID + ") Unable to read configuration
file '" + propsFilePath + "': " + e.toString() + ". Using default port
" + port + ".", e);
}
}
private void loadProperties() {
String tmp = properties.getProperty("port");
port = Integer.parseInt(tmp);
}
Providing Gateway class service and information routines
Several gateway methods perform event gateway configuration services and provide event gateway
information. The ColdFusion event gateway services call many of these methods to configure the
event gateway by using information stored by the ColdFusion MX Administrator, and to get
access to resources and information that are needed by event gateway services and applications.
Some of these methods can also be useful in event gateway code. The following methods provide
these services and information:
setCFCListeners
setGatewayID
getHelper
getGatewayID
getStatus