/************************************************* * * = PACKAGE * JACE.Connection * * = FILENAME * Connector.java * *@author Prashant Jain * *************************************************/ package JACE.Connection; import java.io.*; import java.net.*; import JACE.OS.*; import JACE.SOCK_SAP.*; import JACE.ServiceConfigurator.*; /** *
* Abstract factory for connecting a * (SvcHandler), * to an application. ** *
* Implements the basic strategy for actively establishing connections * with applications. The Connector establishes the connection, * passing it on to a SvcHandler instance, and handing over * control to that instance. ** ** TCP is the transport mechanism used, via * SOCKConnector. *
* This class, as currently implemented, does not work like its C++ counterpart. * Future versions are expected to rectify this discrepancy. ** *@see SOCKConnector,SvcHandler */ public class Connector extends ServiceObject { /** * Create a Connector. Do nothing constructor. Allows user to * call open() later. */ public Connector () { } /** * Create a Connector passing in server hostname and port * number, effectively shorthand for calling * open(). *@param hostname server hostname *@param port server port number */ public Connector (String hostname, int port) { this.open (hostname, port); } /** * Initialize the Connector passing in server hostname and port * number. Note that no connection attempt is made. *@param hostname server hostname *@param port server port number */ public void open (String hostname, int port) { this.hostname_ = hostname; this.port_ = port; } /** * Connect to the server. *@param sh Svc Handler to use to handle the connection */ public void connect (SvcHandler sh) throws UnknownHostException, SocketException, InstantiationException, IllegalAccessException, IOException { // Make a connection using the appropriate Connection_Strategy this.connectSvcHandler (sh); // Activate the Svc_Handler using the appropriate Activation_Strategy this.activateSvcHandler (sh); } /** * Bridge method for making a new connection. The default behavior * creates a new SOCKConnector and then calls setHandle() on the *