Connecting to an Unwired Server Instance

AgentContext and ServerContext are lightweight, immutable Java objects.

Creating either of these objects does not immediately establish a connection to either Sybase Control Center or the Unwired Server.

  1. (Optional) Create an AgentContext object.
    The default constructor creates an instance with host="localhost", port="9999", user="" and password="". The constructor in this sample creates an instance with host="<host name>", port="9999", user="supAdmin" and password="s3pAdmin":
    AgentContext agentContext = new AgentContext();
    agentContext = new AgentContext("<host name>", 9999, "supAdmin", "s3pAdmin");
    
  2. Create a ServerContext object.

    Every ServerContext instance has an AgentContext instance. When you instantiate ServerContext, you can pass an instance of AgentContext to the constructor. If you do not specify an AgentContext, the constructor automatically creates an AgentContext with the same host, user name, and password values as those defined in the ServerContext.

    It also assigns 9999 as the port number for AgentContext, for these reasons:
    • Unwired Server and Sybase Control Center are installed on the same host, and they share the same security provider.
    • By default, Sybase Control Center listens on port 9999. The administration API connects to Sybase Control Center using this port.
    This sample creates a ServerContext that uses values of supAdmin and s3pAdmin for the user name and password, and uses secure port (2001) by specifying "true" in the last parameter:
    ServerContext serverContext = new ServerContext();
    serverContext = new ServerContext("<host name>", 2001, "supAdmin", "s3pAdmin", true);
    

    The usage of secure port does not require server certificate installation on the client-side. It is assumed that server is configured with a valid and secure certificate for transport level security, and client authentication is done via the security provider assigned to the 'admin' security configuration.

Related concepts
Contexts