Adobe COLDFUSION 9 Manual page 1329

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using External Resources
public class SocketHelper implements GatewayHelper {
public SocketHelper() {
}
public coldfusion.runtime.Array getSocketIDs () {
coldfusion.runtime.Array a = new coldfusion.runtime.Array();
Enumeration e = socketRegistry.elements();
while (e.hasMoreElements()) {
a.add(((SocketServerThread)e.nextElement()).getName());
}
return a;
}
public boolean killSocket (String socketid) {
try
{
((SocketServerThread)socketRegistry.get(socketid)).socket.close();
((SocketServerThread)socketRegistry.get(socketid)).socket = null;
socketRegistry.remove(socketid);
return true;
}
catch (IOException e) {
return false;
}
}
}
Gateway configuration file
Gateways can use a configuration file to specify information that does not change frequently. For example, the
ColdFusion SMS event gateway configuration file contains values that include an IP address, port number, system ID,
password, and so on.
You can specify a configuration file path for each event gateway instance in the ColdFusion Administrator.
ColdFusion passes the file path in the gateway constructor when it instantiates the event gateway. The configuration
file format and content handling is up to you. It is the responsibility of the gateway class to parse the file contents and
use it meaningfully.
One good way to access and get configuration data is to use the java.util.Properties class. This class takes an ISO8859-
1 formatted input stream with one property setting per line. Each property name must be separated from the value by
an equal sign (=) or a colon (:), as the following example shows:
ip-address=127.0.0.1
port=4445
The example SocketGateway event gateway uses this technique to get an optional port number from a configuration
file. For an example of reading a properties file and using its data, see the code in
Gateway development classes
ColdFusion provides two classes that you can use as building blocks to develop your event gateway classes. Each
corresponds to a different development methodology:
• The coldfusion.eventgateway.GenericGateway class is an abstract class from which you can derive your gateway
class.
• The EmptyGateway class in the gateway\src\examples directory is a template gateway that you can complete to
create your gateway class.
Last updated 8/5/2010
"Class
constructor" on page 1325.
1324

Advertisement

Table of Contents
loading

Table of Contents