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
ColdFusion MX calls the setCFCListeners
method with the CFC or CFCs that are specified in the ColdFusion MX Administrator when it starts a gateway. ColdFusion MX also calls the method in a running event gateway when the configuration information changes, so the method must be written to handle such changes. The setCFCListeners
method must save the listener information so that the gateway code that dispatches incoming messages to gateway services can use the listener CFCs in setCFCPath
methods.
ColdFusion MX calls the setGatewayID
method when it starts a gateway. The getGatewayID
method must return the value set by this method.
ColdFusion MX calls the getHelper
method when an application calls the CFML GetGatewayHelper
function.
The following code shows how the SocketGateway class defines these methods. To create a new gateway, modify the getHelper
definition to return the correct class, or to return null if there is no gateway helper class. Most gateways do not need to change the other method definitions.
public void setCFCListeners(String[] listeners) { this.listeners = listeners; } public GatewayHelper getHelper() { // SocketHelper class implements the GatewayHelper interface. return new SocketHelper(); } public void setGatewayID(String id) { gatewayID = id; } public String getGatewayID() { return gatewayID; } public int getStatus() { return status; }