Creating a BrokerClient

A Java program wishing to be a Broker module must create an instance of BrokerClient. The BrokerClient differentiates between two different kinds of modules - those that can receive function calls and those that do not implement any function calls of their own.

If you are implementing a client without function calls, use one of the following constructors:

 public BrokerClient(String clientName,
                     InetAddress brokerHost,
                     int brokerPort)
 public BrokerClient(String clientBaseName,
                     String brokerHost,
                     int brokerPort)
Whose only difference is how the host the broker is running on is specified.
For a module with supporting incoming function calls, use one of the following constructors:
 public BrokerClient(String moduleName,
                     String hostName,
                     String portName,
                     ServiceProvider provider,
                     boolean serve) throws UnknownHostException, NumberFormatException
 public BrokerClient(String n,
                     InetAddress h,
                     int p,
                     ServiceProvider provider,
                     boolean serve)
For these constructors, an object implementing the ServiceProvider interface must be specified. It will be called from a new thread for each incoming function/procedure call. The two different methods are for inline and multiline calls.
public interface ServiceProvider
 Object brokerCall( String data ) throws BrokerException;
 Object brokerCall( Vector data ) throws BrokerException;
Note that the BrokerClient will not actually connect to the Broker until you tell it to with the connect method.

Up: Using the Broker Architecture in Java Next: Using the BrokerClient

© Copyright 1997 Erland Lewin and the members of the Center for Speech Technology